@extra-array/has-subsequence
v2.10.19
Published
Checks if array has a subsequence.
Downloads
53
Maintainers
Readme
Checks if array has a subsequence. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Similar: subsequence, subsequences, hasSubsequence, searchSubsequence. Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation, hasPath.
This is part of package extra-array.
array.hasSubsequence(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.hasSubsequence(x, [2, 4]);
// true
array.hasSubsequence(x, [-2, -4]);
// false
array.hasSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true
array.hasSubsequence(x, [-2, -4], null, v => Math.abs(v));
// true