UNPKG

s2-tools

Version:

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

49 lines 1.14 kB
import { compare } from '../../dataStructures/uint64'; /** A local vector key-value store */ export class Vector { #store = []; /** * Push a value into the store * @param value - the value to store */ push(value) { this.#store.push(value); } /** * @param index - the position in the store to get the value from * @returns the value */ async get(index) { return await this.#store[index]; } /** @returns the length of the store */ get length() { return this.#store.length; } /** * iterate through the values * @yields an iterator */ async *values() { for (const value of this.#store) yield value; } /** Sort the store in place */ sort() { this.#store.sort((a, b) => { return compare(a.cell, b.cell); }); } /** * iterate through the values * @returns an iterator */ [Symbol.asyncIterator]() { return this.values(); } /** Closes the store */ close() { this.#store = []; } } //# sourceMappingURL=index.js.map