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