Reference: multikeys
    Preparing search index...

    Class MKWeakMap<K, V>

    Type Parameters

    • K extends object = object
    • V = any
    Index

    Constructors

    Methods

    Constructors

    • Creates a new MKWeakMap object.

      Could be called with initial keys-values

      const empty = new MKWeakMap();
      const withValues = new MKWeakMap([
      [[{foo: 'bar'}], 'val']
      ]);

      Type Parameters

      • K extends object = object
      • V = any

      Parameters

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

      Returns MKWeakMap<K, V>

    Methods

    • Removes any value associated to the keys. Returns true if an element in the MKWeakMap object has been removed successfully.

      const obj = {};
      const mkWeakMap = new MKWeakMap([[obj, 'foo']]);

      mkWeakMap.delete([obj]); // => true
      mkWeakMap.delete([obj]); // => false

      Parameters

      • keys: readonly K[]

      Returns boolean

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

      const obj = {};
      const mkWeakMap = new MKWeakMap([[obj, 'foo']]);

      mkWeakMap.get([obj]); // => 'foo'

      Parameters

      • keys: readonly K[]

      Returns undefined | V

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

      const obj = {};
      const mkWeakMap = new MKWeakMap([[obj, 'foo']]);

      mkWeakMap.has([obj]); // => 'true'

      Parameters

      • keys: readonly K[]

      Returns boolean

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

      const mkWeakMap = new MKWeakMap();
      const obj = {};

      mkWeakMap.set([obj], 'foo');
      mkWeakMap.get([obj]); // => 'foo'

      Parameters

      • keys: readonly K[]
      • value: V

      Returns this