UNPKG

@hgargg-0710/one

Version:

A tiny npm library purposed for providing beautiful solutions to frequent miniature (one-line/one-expression) tasks for various JS datatypes.

17 lines (16 loc) 403 B
/** * Returns the pair of arrays of keys and values of the given `Map` */ export const kv = (map) => [ Array.from(map.keys()), Array.from(map.values()) ]; /** * Returns the new `Map` built from the key-value pairs passed */ export const dekv = ([keys, values]) => { const map = new Map(); for (let i = 0; i < keys.length; ++i) map.set(keys[i], values[i]); return map; };