UNPKG

@benev/nubs

Version:
58 lines 3.3 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var _RegulatedSet_instances, _RegulatedSet_set, _RegulatedSet_on_change, _RegulatedSet_call_change; export class RegulatedSet { constructor(set, on_change) { _RegulatedSet_instances.add(this); _RegulatedSet_set.set(this, void 0); _RegulatedSet_on_change.set(this, void 0); this.readable = { forEach: this.forEach.bind(this), has: this.has.bind(this), array: this.array.bind(this), }; __classPrivateFieldSet(this, _RegulatedSet_set, set, "f"); __classPrivateFieldSet(this, _RegulatedSet_on_change, on_change, "f"); } // writing methods add(...items) { for (const x of items) __classPrivateFieldGet(this, _RegulatedSet_set, "f").add(x); __classPrivateFieldGet(this, _RegulatedSet_instances, "m", _RegulatedSet_call_change).call(this); } delete(item) { __classPrivateFieldGet(this, _RegulatedSet_set, "f").delete(item); __classPrivateFieldGet(this, _RegulatedSet_instances, "m", _RegulatedSet_call_change).call(this); } clear() { __classPrivateFieldGet(this, _RegulatedSet_set, "f").clear(); __classPrivateFieldGet(this, _RegulatedSet_instances, "m", _RegulatedSet_call_change).call(this); } assign(items) { __classPrivateFieldGet(this, _RegulatedSet_set, "f").clear(); for (const item of items) __classPrivateFieldGet(this, _RegulatedSet_set, "f").add(item); __classPrivateFieldGet(this, _RegulatedSet_instances, "m", _RegulatedSet_call_change).call(this); } // reading methods forEach(f) { __classPrivateFieldGet(this, _RegulatedSet_set, "f").forEach(f); } has(item) { return __classPrivateFieldGet(this, _RegulatedSet_set, "f").has(item); } array() { return [...__classPrivateFieldGet(this, _RegulatedSet_set, "f")]; } } _RegulatedSet_set = new WeakMap(), _RegulatedSet_on_change = new WeakMap(), _RegulatedSet_instances = new WeakSet(), _RegulatedSet_call_change = function _RegulatedSet_call_change() { __classPrivateFieldGet(this, _RegulatedSet_on_change, "f").call(this, this.readable); }; //# sourceMappingURL=regulated-set.js.map