predictype / arrays / arraySequence
arraySequence<
T
>(source
,oper
,target
):boolean
Defined in: predicates/arrays/arraySequence.ts:29
Checks if the source array contains, starts with, or ends with a given subsequence, using the specified operation.
T
Type of the array elements.
T
[]
The source array.
The sequence operation to perform (e.g. ‘contains_subsequence’, ‘starts_with’, ‘ends_with’).
T
[]
The target subsequence array to check against the source.
boolean
True if the sequence check is valid according to the operator, otherwise false.
If the operation is not recognized.
const arr1 = [1, 2, 3, 4];
const arr2 = [2, 3];
const arr3 = [1, 2, 3];
const arr4 = [1, 2];
arraySequence(arr1, 'contains_subsequence', arr2); // true
arraySequence(arr3, 'starts_with', arr4); // true
Supported Operators: