UNPKG

s2-tools

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

46 lines 1.13 kB
/** Just a placeholder to explain what a local key-value store essentially is */ export class KV { #store = new Map(); /** @returns - the length of the map */ get length() { return this.#store.size; } /** * Gets the list of values associated with a key * @param key - the key * @returns the list of values if the map contains values for the key */ get(key) { return this.#store.get(key); } /** * Adds a value to the list of values associated with a key * @param key - the key * @param value - the value to store */ set(key, value) { this.#store.set(key, value); } /** * iterate through the values * @yields an iterator */ async *values() { for await (const [, value] of this.#store.entries()) yield value; } /** * iterate through the values * @returns an iterator */ [Symbol.asyncIterator]() { return this.values(); } /** * Closes the store */ close() { this.#store.clear(); } } //# sourceMappingURL=index.js.map