Returns the first slice of the array of length len from the right (starting with slice(len - 1), then slice(len - 1), etc.) which passes condition. Returns undefined if no slice of the array ending with the last element passes.
len
slice(len - 1)
condition
undefined
import * as A from "flurp/array";import * as N from "flurp/number";const twoPositive = (arr: ReadonlyArray<number>) => A.count(N.isPositive)(arr) >= 2;const firstSlice = A.findSliceRight(twoPositive);firstSlice([2, -4, 1, -5, 6]); // [1, -5, 6]firstSlice([2, -4]); // undefined
Returns the first slice of the array of length
len
from the right (starting withslice(len - 1)
, thenslice(len - 1)
, etc.) which passescondition
. Returnsundefined
if no slice of the array ending with the last element passes.Example