@extra-array/is-prefix

Checks if array starts with a prefix.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/is-prefix
1622.9.643 years ago3 years agoMinified + gzip package size for @extra-array/is-prefix in KB

Readme

Checks if array starts with a prefix. :running: :vhs: :package: :moon: :ledger:
Similar: prefix, prefixes, isPrefix.
Similar: isValue, isPrefix, isInfix, isSuffix, isSubsequence, isPermutation.
This is part of package extra-array.

array.isPrefix(x, y, [fc], [fm]);
// x:  an array
// y:  prefix?
// fc: compare function (a, b)
// fm: map function (v, i, x)

const array = require('extra-array');

var x = [1, 2, 3, 4];
array.isPrefix(x, [1, 2]);
// true

array.isPrefix(x, [-1, -2]);
// false

array.isPrefix(x, [-1, -2], (a, b) => Math.abs(a) - Math.abs(b));
// true

array.isPrefix(x, [-1, -2], null, v => Math.abs(v));
// true

references