0.1.5 • Published 6 years ago
iterable-mapreplace v0.1.5
iterable-mapreplace
NOTE: iterable-mapreplace was renamed to @extra-iterable/map-replace.
Replace values in iterable with a map.
const mapReplace = require('iterable-mapreplace');
// mapReplace(<iterable>, <map>, [begin=0], [end], [target=[]], [at])
mapReplace(new Set(['shiwalik', 'range']), new Map([['range', 'mountains']]));
// ['shiwalik', 'mountains']
mapReplace([0, 1, 2, 3], new Map([[1, -1], [2, -2]]), 1);
// [-1, -2, 3]
mapReplace([0, 1, 2, 3], new Map([[1, -1], [2, -2]]), 1, 3);
// [-1, -2]
mapReplace([0, 1, 2, 3], new Map([[1, -1], [2, -2]]), 1, 3, [10, 11]);
// [10, 11, -1, -2]
mapReplace([0, 1, 2, 3], new Map([[1, -1], [2, -2]]), 1, 3, [10, 11], 1);
// [10, -1, -2]