Skip to main content

Class: Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:20

Wrapper around IterableIterator interface offering a set of helpers to deal with iterations in a simple way

Remarks​

Since 0.0.7

Type Parameters​

Type Parameter
T

Implements​

  • IterableIterator<T>

Constructors​

Constructor​

new Stream<T>(g): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:46

Create a Stream based on g

Parameters​

ParameterTypeDescription
gIterableIterator<T>Underlying data of the Stream

Returns​

Stream<T>

Methods​

[iterator]()​

[iterator](): IterableIterator<T>

Defined in: packages/fast-check/src/stream/Stream.ts:58

Returns​

IterableIterator<T>

Implementation of​

IterableIterator.[iterator]


drop()​

drop(n): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:114

Drop n first elements of the Stream

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
nnumberNumber of elements to drop

Returns​

Stream<T>

Remarks​

Since 0.0.1


dropWhile()​

dropWhile(f): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:96

Drop elements from the Stream while f(element) === true

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
f(v) => booleanDrop condition

Returns​

Stream<T>

Remarks​

Since 0.0.1


every()​

every(f): boolean

Defined in: packages/fast-check/src/stream/Stream.ts:180

Check whether all elements of the Stream are successful for f

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
f(v) => booleanCondition to check

Returns​

boolean

Remarks​

Since 0.0.1


filter()​

Call Signature​

filter<U>(f): Stream<U>

Defined in: packages/fast-check/src/stream/Stream.ts:157

Filter elements of the Stream

WARNING: It closes the current stream

Type Parameters​
Type Parameter
U
Parameters​
ParameterTypeDescription
f(v) => v is UElements to keep
Returns​

Stream<U>

Remarks​

Since 1.23.0

Call Signature​

filter(f): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:166

Filter elements of the Stream

WARNING: It closes the current stream

Parameters​
ParameterTypeDescription
f(v) => booleanElements to keep
Returns​

Stream<T>

Remarks​

Since 0.0.1


flatMap()​

flatMap<U>(f): Stream<U>

Defined in: packages/fast-check/src/stream/Stream.ts:83

Flat map all elements of the Stream using f

WARNING: It closes the current stream

Type Parameters​

Type Parameter
U

Parameters​

ParameterTypeDescription
f(v) => IterableIterator<U>Mapper function

Returns​

Stream<U>

Remarks​

Since 0.0.1


getNthOrLast()​

getNthOrLast(nth): T | null

Defined in: packages/fast-check/src/stream/Stream.ts:228

Take the nth element of the Stream of the last (if it does not exist)

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
nthnumberPosition of the element to extract

Returns​

T | null

Remarks​

Since 0.0.12


has()​

has(f): [boolean, T | null]

Defined in: packages/fast-check/src/stream/Stream.ts:197

Check whether one of the elements of the Stream is successful for f

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
f(v) => booleanCondition to check

Returns​

[boolean, T | null]

Remarks​

Since 0.0.1


join()​

join(...others): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:215

Join others Stream to the current Stream

WARNING: It closes the current stream and the other ones (as soon as it iterates over them)

Parameters​

ParameterTypeDescription
...othersIterableIterator<T, any, any>[]Streams to join to the current Stream

Returns​

Stream<T>

Remarks​

Since 0.0.1


map()​

map<U>(f): Stream<U>

Defined in: packages/fast-check/src/stream/Stream.ts:71

Map all elements of the Stream using f

WARNING: It closes the current stream

Type Parameters​

Type Parameter
U

Parameters​

ParameterTypeDescription
f(v) => UMapper function

Returns​

Stream<U>

Remarks​

Since 0.0.1


next()​

next(): IteratorResult<T>

Defined in: packages/fast-check/src/stream/Stream.ts:55

Returns​

IteratorResult<T>

Implementation of​

IterableIterator.next


take()​

take(n): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:144

Take n first elements of the Stream

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
nnumberNumber of elements to take

Returns​

Stream<T>

Remarks​

Since 0.0.1


takeWhile()​

takeWhile(f): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:132

Take elements from the Stream while f(element) === true

WARNING: It closes the current stream

Parameters​

ParameterTypeDescription
f(v) => booleanTake condition

Returns​

Stream<T>

Remarks​

Since 0.0.1


nil()​

static nil<T>(): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:25

Create an empty stream of T

Type Parameters​

Type Parameter
T

Returns​

Stream<T>

Remarks​

Since 0.0.1


of()​

static of<T>(...elements): Stream<T>

Defined in: packages/fast-check/src/stream/Stream.ts:35

Create a stream of T from a variable number of elements

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
...elementsT[]Elements used to create the Stream

Returns​

Stream<T>

Remarks​

Since 2.12.0