gis-tools-ts - v0.6.0
    Preparing search index...

    Class FileKV<V>

    Key-Value File Store

    A filesystem key-value store

    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();

    Type Parameters

    • V = Properties | Value

    Implements

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Builds a new MultiMap file store

      Type Parameters

      • V = Value | Properties

      Parameters

      • OptionalfileName: string

        the path + file name without the extension

      Returns FileKV<V>

    Accessors

    • get length(): number

      Returns number

      • the length of the map

    Methods

    • iterate through the values

      Returns AsyncGenerator<V>

      an iterator

    • Closes the store

      Returns void

    • Gets the list of values associated with a key

      Parameters

      • key: number | bigint

        the key

      Returns Promise<undefined | V>

      the list of values if the map contains values for the key

    • Check if the key exists

      Parameters

      • key: number | bigint

        the key

      Returns Promise<boolean>

      true if the key exists

    • Adds a value to the list of values associated with a key

      Parameters

      • key: number | bigint

        the key

      • value: V

        the value to store

      Returns void

    • iterate through the values

      Returns AsyncGenerator<V>

      an iterator