@extra-array/is-subsequence-on
v2.7.8
Published
Checks if array has a subsequence.
Downloads
130
Maintainers
Readme
Checks if array has a subsequence. :running: :vhs: :package: :moon:
Alternatives: compare, map. Similar: subsequence, subsequences, isSubsequence. This is part of package extra-array.
array.isSubsequenceOn(x, y, [fn], [ths]);
// x: an array
// y: subsequence?
// fn: map function (v, i, x)
// ths: this argument
const array = require('extra-array');
var x = [1, 2, 3, 4];
array.isSubsequenceOn(x, [2, 4]);
// true
array.isSubsequenceOn(x, [-2, -4]);
// false
array.isSubsequenceOn(x, [-2, -4], v => Math.abs(v));
// true