An array of filtered and mapped values.
From tsur.
first
finds the first item that matches a predicate. Returns the first item of array if no predicate is provided.
Optional
predicate: ((value: T, index: number, array: T[]) => boolean)A predicate function.
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
The first item that matches the predicate, or None
if no item matches.
From tsur.
Returns the index of the first element in the array that satisfies the provided testing function. Otherwise None
is returned.
A predicate function.
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
The index of the first item that matches the predicate, or None
if no item matches.
From tsur.
Applies function to the elements of iterator and returns the first non-none result.
firstMap(fn)
is the lighter version of filterMap(fn).first()
.
The first non-none result.
From tsur.
last
finds the last item that matches a predicate. Returns the last item of array if no predicate is provided.
Optional
predicate: ((value: T, index: number, array: T[]) => boolean)A predicate function.
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
The last item that matches the predicate, or None
if no item matches.
From tsur.
Returns the index of the last element in the array where predicate is true, and None
otherwise.
lastIndex calls predicate once for each element of the array, in backward order, until it finds one where predicate returns true.
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
The index of the last item that matches the predicate, or None
if no item matches.
From tsur.
lastMap(fn)
is the lighter version of filterMap(fn).last()
.
The last non-none result.
From tsur.
mapWhile
maps an iterable until the first None
is encountered.
An array of mapped values.
From tsur.
reduceWhile
reduces an iterable until the first None
is encountered.
A function that produces an Option
.
The initial value.
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
The reduced value.
From tsur.
filterMap
filers and maps an iterable at the same time.It makes chains of
filter
andmap
more concise, as it shortensmap().filter().map()
to a single call.