Function fromIterable

import { Maps } from 'https://unpkg.com/ixfx/dist/data.js'; Returns a Map from an iterable. By default throws an exception if iterable contains duplicate values.

const data = [
{ fruit: `granny-smith`, family: `apple`, colour: `green` }
{ fruit: `mango`, family: `stone-fruit`, colour: `orange` }
];
const map = Maps.fromIterable(data, v => v.fruit);
  • Type Parameters

    • V

    Parameters

    • data: Iterable<V>

      Input data

    • keyFunction: ((itemToMakeStringFor: V) => string) = ...

      Function which returns a string id. By default uses the JSON value of the object.

        • (itemToMakeStringFor): string
        • A default converter to string that uses JSON.stringify if its an object, or the thing itself if it's a string

          Parameters

          • itemToMakeStringFor: V

          Returns string

    • allowOverwrites: boolean = false

      When set to true, items with same id will silently overwrite each other, with last write wins. false by default.

    Returns ReadonlyMap<string, V>