@extra-array/search-subsequence
v2.10.19
Published
Finds first index of a subsequence.
Downloads
87
Maintainers
Readme
Finds first index of a subsequence. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Similar: subsequence, subsequences, hasSubsequence, searchSubsequence. Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation.
This is part of package extra-array.
array.searchSubsequence(x, y, [fc], [fm]);
// x: an array
// y: subsequence?
// fc: compare function (a, b)
// fm: map function (v, i, x)
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.searchSubsequence(x, [2, 4]);
// 1
array.searchSubsequence(x, [-2, -4]);
// -1
array.searchSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b));
// 1
array.searchSubsequence(x, [-2, -4], null, v => Math.abs(v));
// 1