-
Notifications
You must be signed in to change notification settings - Fork 1
hasPrefix
Subhajit Sahu edited this page Feb 3, 2021
·
11 revisions
Check if iterable starts with a prefix.
Alternatives: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPath.
function hasPrefix(x, y, fc, fm)
// x: an iterable
// y: search prefix
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');
var x = [1, 2, 3, 4];
xiterable.hasPrefix(x, [1, 2]);
// → true
xiterable.hasPrefix(x, [-1, -2]);
// → false
xiterable.hasPrefix(x, [-1, -2], (a, b) => Math.abs(a) - Math.abs(b));
// → true
xiterable.hasPrefix(x, [-1, -2], null, v => Math.abs(v));
// → true