-
Notifications
You must be signed in to change notification settings - Fork 1
merge
Subhajit Sahu edited this page Feb 3, 2021
·
14 revisions
Merge values from sorted iterables.
Similar: [sort], merge.
function merge(xs, fc, fm)
// xs: iterables
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');
var x = [1, 3, 5, 7];
var y = [2, 4, 8];
[...xiterable.merge([x, y])];
// → [
// 1, 2, 3, 4,
// 5, 7, 8
//]
var y = [-2, -4, -8];
[...xiterable.merge([x, y], (a, b) => Math.abs(a) - Math.abs(b))];
// → [
// 1, -2, 3, -4,
// 5, 7, -8
//]
[...xiterable.merge([x, y], null, v => Math.abs(v))];
// → [
// 1, -2, 3, -4,
// 5, 7, -8
//]