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