Stream
Stream:
object
Defined in: src/stream/Streams.ts:35
Factories for Stream.
Type Declaration
Section titled “Type Declaration”iterate
Section titled “iterate”iterate: {<
T>(seed,f):Stream<T>; <T>(seed,hasNext,next):Stream<T>; }
iterate(seed, f): returns the infinite ordered stream seed, f(seed), f(f(seed)), …; limit it with
limit or takeWhile. iterate(seed, hasNext, next): returns the ordered stream a
for (t = seed; hasNext(t); t = next(t)) loop would visit.
Call Signature
Section titled “Call Signature”<
T>(seed,f):Stream<T>
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T
(t) => T
Returns
Section titled “Returns”Stream<T>
Call Signature
Section titled “Call Signature”<
T>(seed,hasNext,next):Stream<T>
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T
hasNext
Section titled “hasNext”(t) => boolean
(t) => T
Returns
Section titled “Returns”Stream<T>
Throws
Section titled “Throws”NullPointerException if a function argument is null
builder()
Section titled “builder()”builder<
T>():StreamBuilder<T>
Returns a StreamBuilder that collects elements one at a time and then builds a stream of them.
Type Parameters
Section titled “Type Parameters”T
Returns
Section titled “Returns”concat()
Section titled “concat()”concat<
T>(a,b):Stream<T>
Returns a lazy stream of all elements of a followed by all of b. Both inputs count as used; the result is
parallel if either input is, and closing it closes both. Nesting concat thousands of times deep is quadratic
and can overflow the call stack: use flatMap to join many streams.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Stream<T>
Stream<T>
Returns
Section titled “Returns”Stream<T>
Throws
Section titled “Throws”NullPointerException if a or b is null
empty()
Section titled “empty()”empty<
T>():Stream<T>
Returns an empty stream.
Type Parameters
Section titled “Type Parameters”T
Returns
Section titled “Returns”Stream<T>
from()
Section titled “from()”from<
T>(iterable):Stream<T>
Returns a stream over any JS iterable (an addition to the reference API). Arrays are read like ofArray and
this library’s collections through their own spliterators; any other iterable is read through its JS iterator
(ordered, unknown size), which is closed (its finally runs) when the stream stops early or is closed.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
Returns
Section titled “Returns”Stream<T>
Throws
Section titled “Throws”NullPointerException if iterable is null
generate()
Section titled “generate()”generate<
T>(s):Stream<T>
Returns an infinite, unordered stream of the values s() returns, called once per element pulled.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”() => T
Returns
Section titled “Returns”Stream<T>
Throws
Section titled “Throws”NullPointerException if s is null
of<
T>(…values):Stream<T>
Returns an ordered, sized stream of the given values (null allowed).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”values
Section titled “values”…T[]
Returns
Section titled “Returns”Stream<T>
ofArray()
Section titled “ofArray()”ofArray<
T>(array):Stream<T>
Returns an ordered, sized stream over the array itself, without copying (an addition to the reference API).
The range (0 to the length at creation) is fixed; elements are read when the terminal operation runs.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”ArrayLike<T>
Returns
Section titled “Returns”Stream<T>
Throws
Section titled “Throws”NullPointerException if array is null
ofNullable()
Section titled “ofNullable()”ofNullable<
T>(t):Stream<T>
Returns a stream of t, or an empty stream when t is null or undefined.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T | null | undefined
Returns
Section titled “Returns”Stream<T>