UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

27 lines 557 B
/** * An in-memory storage class. * * @group Storages */ export class MemoryStorage { #data = {}; get length() { return Object.keys(this.#data).length; } clear() { this.#data = {}; } getItem(key) { return (key in this.#data && this.#data[key]) || null; } key(index) { return Object.keys(this.#data)[index] ?? null; } removeItem(key) { delete this.#data[key]; } setItem(key, value) { this.#data[key] = value; } } //# sourceMappingURL=MemoryStorage.js.map