mwg API
    Preparing search index...

    Function readTableMap

    • Projects rows into a typed map. An array of column names is a native composite key and is encoded without collisions between strings, numbers, booleans, and null.

      Type Parameters

      • Row extends Record<string, unknown>
      • Value = Row

      Parameters

      Returns Map<string, Value>

      import { readTableMap, tableKey } from '@datamoc/mw_games/mwl';
      const effects = [{ item: 'potion', effect: 'heal', amount: 5 }];
      const byEffect = readTableMap(effects, { key: ['item', 'effect'], value: (row) => row.amount });
      console.log(byEffect.get(tableKey('potion', 'heal'))); // 5