2.1.0 • Published 4 years ago
@extra-lists/is-submap v2.1.0
Checks if lists has a submap. :running: :package: :ledger:
Similar: subobject, subobjects, isSubobject. This is part of package extra-lists.
lists.isSubmap(x, y, [fc], [fm]);
// x: lists
// y: submap?
// fc: compare function (a, b)
// fm: map function (v, k, x)
const lists = require('extra-lists');
var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['b', 'd'], [2, 4]];
lists.isSubmap(x, y);
// true
var y = [['b', 'd'], [-2, -4]];
lists.isSubmap(x, y);
// false
lists.isSubmap(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// true
lists.isSubmap(x, y, null, v => Math.abs(v));
// true