gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
73 lines • 2 kB
TypeScript
import type { KVStore } from './index.js';
import type { S2CellId } from '../../index.js';
import type { Properties, Value } from '../../index.js';
/**
* # Key-Value File Store
*
* ## Description
* A filesystem key-value store
*
* ## Usage
* ```ts
* import { FileKV } from 'gis-tools-ts/file';
*
* interface Data { name: string };
*
* const kv = new FileKV<Data>('./test.kv');
* // set a key
* kv.set(1n, { name: 'test' });
* // get a key
* const { name } = kv.get(1n); // { name: 'test' }
* // check if a key exists
* kv.has(1n); // true
* // get length of the store
* console.log(kv.length); // 1
*
* // iterate over the store
* for await (const value of kv) console.log(value);
*
* // close the store
* kv.close();
* ```
*/
export declare class FileKV<V = Properties | Value> implements KVStore<V> {
#private;
/**
* Builds a new MultiMap file store
* @param fileName - the path + file name without the extension
*/
constructor(fileName?: string);
/** @returns - the length of the map */
get length(): number;
/**
* Adds a value to the list of values associated with a key
* @param key - the key
* @param value - the value to store
*/
set(key: number | S2CellId, value: V): void;
/**
* Check if the key exists
* @param key - the key
* @returns true if the key exists
*/
has(key: number | S2CellId): Promise<boolean>;
/**
* 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: number | S2CellId): Promise<V | undefined>;
/**
* iterate through the values
* @yields {V} - the values iterator
*/
values(): AsyncGenerator<V>;
/**
* iterate through the values
* @returns an iterator
*/
[Symbol.asyncIterator](): AsyncGenerator<V>;
/** Closes the store */
close(): void;
}
//# sourceMappingURL=file.d.ts.map