UNPKG

@speckle/objectloader2

Version:

This is an updated objectloader for the Speckle viewer written in typescript

49 lines 1.26 kB
export default class KeyedQueue { _map; _order; constructor() { this._map = new Map(); this._order = []; } enqueue(key, value) { if (this._map.has(key)) { return false; // Key already exists } this._map.set(key, value); this._order.push(key); return true; } enqueueAll(keys, values) { let count = 0; for (let i = 0; i < keys.length; i++) { if (!this._map.has(keys[i])) { this._map.set(keys[i], values[i]); this._order.push(keys[i]); count++; } } return count; } get(key) { return this._map.get(key); } has(key) { return this._map.has(key); } get size() { return this._order.length; } spliceValues(start, deleteCount) { const splicedKeys = this._order.splice(start, deleteCount); const result = []; for (const key of splicedKeys) { const value = this._map.get(key); if (value !== undefined) { result.push(value); this._map.delete(key); } } return result; } } //# sourceMappingURL=keyedQueue.js.map