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.
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 Copy
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
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.