UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

48 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObservableMap = void 0; const core_1 = require("@ng-doc/core"); const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); class ObservableMap { constructor(values) { this.collection = new Map(); this.changes$ = new rxjs_1.ReplaySubject(); this.collection = new Map(values); } get size() { return this.collection.size; } *[Symbol.iterator]() { yield* this.collection; } keys() { return (0, core_1.asArray)(this.collection.keys()); } asArray() { return (0, core_1.asArray)(this.collection.values()); } changes() { return this.changes$.pipe((0, operators_1.map)(() => this.asArray())); } add(...items) { items.forEach(([key, value]) => this.collection.set(key, value)); this.changes$.next(); return () => { items.forEach(([key]) => this.delete(key)); }; } get(key) { return this.collection.get(key); } delete(key) { this.collection.delete(key); this.changes$.next(); } clear() { this.collection.clear(); this.changes$.next(); } } exports.ObservableMap = ObservableMap; //# sourceMappingURL=observable-map.js.map