ts-data-forge
    Preparing search index...
    • Creates a new IMap instance from an iterable of key-value pairs.

      This factory function accepts any iterable of [key, value] tuples, including arrays, JavaScript Maps, other IMaps, or custom iterables. The resulting IMap will contain all the entries from the input iterable.

      Performance: O(n) where n is the number of entries in the iterable.

      Type Parameters

      • K extends Primitive

        The type of the keys. Must extend MapSetKeyType.

      • V

        The type of the values.

      Parameters

      • iterable: Iterable<readonly [K, V]>

        An iterable of key-value pairs (e.g., Array, Map, IMap, etc.)

      Returns IMap<K, V>

      A new IMap instance containing all entries from the iterable.

      const map = IMap.create<string, number | string>([
      ['id', 1],
      ['status', 'active'],
      ]);

      assert(map.size === 2);
      assert.deepStrictEqual(map.get('status'), Optional.some('active'));