-
Notifications
You must be signed in to change notification settings - Fork 1
fromKeys
Subhajit Sahu edited this page Dec 5, 2022
·
1 revision
Create a map from keys.
Similar: from, fromLists, fromKeys, fromValues.
function fromKeys(x, fm)
// x: keys
// fm: map function for values (v, i, x)
const {fromKeys} = require('extra-map');
var ks = ['a', 'b', 'c'];
map.fromKeys(ks);
// → Map(3) { 'a' => 'a', 'b' => 'b', 'c' => 'c' }
map.fromKeys(ks, k => k.charCodeAt(0) - 97 + 1);
// → Map(3) { 'a' => 1, 'b' => 2, 'c' => 3 }