hasInfix - nodef/extra-iterable GitHub Wiki

Check if iterable contains an infix.

Alternatives: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPath. Similar: hasInfix, searchInfix.

function hasInfix(x, y, fc, fm)
// x:  an iterable
// y:  search infix
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');

var x = [1, 2, 3, 4];
xiterable.hasInfix(x, [2, 3]);
// → true

xiterable.hasInfix(x, [-2, -3]);
// → false

xiterable.hasInfix(x, [-2, -3], (a, b) => Math.abs(a) - Math.abs(b));
// → true

xiterable.hasInfix(x, [-2, -3], null, v => Math.abs(v));
// → true

References