searchInfixAll - nodef/extra-iterable GitHub Wiki

Find indices of an infix.

Alternatives: searchInfix, searchInfixRight, searchInfixAll. Similar: hasInfix, searchInfix. Similar: search, [scan], find.

function searchInfixAll(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, -2, -3];
var y = [2, 3];
[...xiterable.searchInfixAll(x, y)];
// → [1]

var y = [-2, -3];
[...xiterable.searchInfixAll(x, y)];
// → [4]

[...xiterable.searchInfixAll(x, y, (a, b) => Math.abs(a) - Math.abs(b))];
// → [1, 4]

[...xiterable.searchInfixAll(x, y, null, v => Math.abs(v))];
// → [1, 4]

References