not.js (698B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /* global ConditionBase */ 6 7 /** 8 * NOT condition 9 */ 10 class ConditionNot extends ConditionBase { 11 #condition; 12 13 constructor(factory, desc) { 14 super(factory, desc); 15 this.#condition = desc?.condition ? factory.create(desc.condition) : null; 16 } 17 18 async init() { 19 if (this.#condition) { 20 await this.#condition.init(); 21 } 22 } 23 24 check() { 25 if (!this.#condition) { 26 return true; 27 } 28 return !this.#condition.check(); 29 } 30 } 31 32 globalThis.ConditionNot = ConditionNot;