UNPKG

docxml

Version:

TypeScript (component) library for building and parsing a DOCX file

46 lines (45 loc) 1.99 kB
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 __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 _NumberMap_start; /** * A special kind of map that makes it easy to store items by a number, automatically ensuring that * these identifiers increment and don't collide. */ export class NumberMap extends Map { constructor(start = 0) { super(); _NumberMap_start.set(this, void 0); __classPrivateFieldSet(this, _NumberMap_start, start, "f"); } getNextAvailableKey() { let i = __classPrivateFieldGet(this, _NumberMap_start, "f"); while (this.has(i)) { ++i; } return i; } /** * Add new data to the map, and return the new unique key. */ add(data) { const key = this.getNextAvailableKey(); this.set(key, data); return key; } /** * Get all values in an array. */ array() { return Array.from(this.values()); } } _NumberMap_start = new WeakMap();