1.1.1 • Published 6 years ago

@extra-iterable/map-replace v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Replace values in iterable with a map.

const mapReplace = require('@extra-iterable/map-replace');
// 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]

extra-iterable