UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

31 lines 686 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MemoryStorage = void 0; /** * An in-memory storage class. * * @group Storages */ 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]; } removeItem(key) { delete this.#data[key]; } setItem(key, value) { this.#data[key] = value; } } exports.MemoryStorage = MemoryStorage; //# sourceMappingURL=MemoryStorage.js.map