ixfx
    Preparing search index...

    Function addKeepingExisting

    • Adds items to a map only if their key doesn't already exist

      Uses provided Util.ToString function to create keys for items. Item is only added if it doesn't already exist. Thus the older item wins out, versus normal Map.set where the newest wins.

      Type Parameters

      • V

      Parameters

      • set: undefined | ReadonlyMap<string, V>
      • hasher: ToString<V>
      • ...values: readonly V[]

      Returns Map<any, any>

      import { Maps } from "https://unpkg.com/ixfx/dist/collections.js";
      const map = new Map();
      const peopleArray = [ _some people objects..._];
      Maps.addKeepingExisting(map, p => p.name, ...peopleArray);