Reference: multikeys
    Preparing search index...

    Class MKMap<K, V>

    Type Parameters

    • K = any
    • V = any
    Index

    Constructors

    • Creates a new MKMap object.

      Could be called with initial keys-values.

      const empty = new MKMap();
      const withValues = new MKMap([
      [['key_1', 'key_2'], 'value'],
      [['key'], 'val']
      ]);

      Type Parameters

      • K = any
      • V = any

      Parameters

      • Optionaliterable: Iterable<readonly [readonly K[], V], any, any>

      Returns MKMap<K, V>

    Accessors

    • get size(): number

      Returns the number of keys/value pairs in the MKMap object.

      Returns number

    Methods

    • Returns a new Iterator object that contains an array of [keys, value] for each element in the MKMap object.

      Returns IterableIterator<[K[], V]>

    • Removes all keys-value pairs from the MKMap object.

      Returns void

    • Returns true if an element in the MKMap object existed and has been removed, or false if the element does not exist.

      const mkMap = new MKMap([['foo'], 'bar']);

      mkMap.delete(['foo']); // => true
      mkMap.delete(['foo']); // => false

      Parameters

      • keys: readonly K[]

      Returns boolean

    • Returns a new Iterator object that contains an array of [keys, value] for each element in the Map object.

      Returns IterableIterator<[K[], V]>

    • Calls callbackFn once for each keys-value pair present in the MKMap object.

      Parameters

      • callbackFn: (value: V, keys: K[], map: this) => void

      Returns void

    • Returns the value associated to the keys, or undefined if there is none.

      const mkMap = new MKMap([['foo'], 'bar']);

      mkMap.get(['foo']); // => 'bar'

      Parameters

      • keys: readonly K[]

      Returns undefined | V

    • Returns a boolean asserting whether a value has been associated to the keys in the MKMap object or not.

      const mkMap = new MKMap([['foo'], 'bar']);

      mkMap.has(['foo']); // => true

      Parameters

      • keys: readonly K[]

      Returns boolean

    • Returns a new Iterator object that contains the keys for each element in the MKMap.

      Returns IterableIterator<K[]>

    • Sets the value for the keys in the MKMap object. Returns the MKMap object.

      mkMap.set(['foo'], 'bar');
      

      Parameters

      • keys: readonly K[]
      • value: V

      Returns this

    • Returns a new Iterator object that contains the values for each element in the MKMap object.

      Returns IterableIterator<V>