Returns the elements of the stream that meet the condition specified in a callback function. The function is called when the resulting stream elements are actually accessed, so accessing the resulting stream multiple times means the function is also called multiple times for each element of the stream.
Returns a new stream with all sub-stream or sub-array elements concatenated into it recursively up to the specified depth.
Optional
depth: DThe maximum recursion depth. Defaults to 1.
Determines whether the stream includes a certain element, returning true
or false
as appropriate.
The element to search for.
Returns the index of the first occurrence of a value in the stream, or -1 if it is not present.
The value to locate in the array.
Optional
fromIndex: numberThe stream index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
Adds all elements of the stream into a string, separated by the specified separator string.
Optional
separator: stringA string used to separate one element of the stream from the next in the resulting string. If omitted, the steam elements are separated with a comma.
Returns a stream that yields the results of calling the specified callback function on each element of the stream. The function is called when the resulting stream elements are actually accessed, so accessing the resulting stream multiple times means the function is also called multiple times for each element of the stream.
Calls the specified callback function for all elements in the stream. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
Calls the specified callback function for all elements in the stream, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
A stream is a read-only sequence of values. While the contents of an array can be accessed both sequentially and randomly (via index), a stream allows only sequential access.
The advantage of this is that a stream can be evaluated lazily, so it does not require to store intermediate values. This can boost performance when a large sequence is processed via filtering, mapping etc. and accessed at most once. However, lazy evaluation means that all processing is repeated when you access the sequence multiple times; in such a case, it may be better to store the resulting sequence into an array.