The Stream is the base class of all other streams.
single()
Returns the produced value.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('a static value');console.log(stream.single());// 'a static value'
many()
Returns the produced array.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('a static value');console.log(stream.many(2));// ['a static value', 'a static value']
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').array(3).map(i =>i.toUpperCase());console.log(stream.single());// ['VALUE', 'VALUE', 'VALUE']
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').format('VALUE IS ${:upperCase()}');console.log(stream.single());// 'VALUE IS VALUE
optional()
Returns a Stream that may produce value or undefined.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').optional(0.3);console.log(stream.single());// undefined or 'value'
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').nullable(0.3);console.log(stream.single());// null or 'value'
convert()
Returns a Stream with maps the produced value to another type.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').convert(i =>i.length);console.log(stream.single());// 5
apply()
Returns a Stream with maps the produced value to the same type.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').apply(i =>i.padStart(7,'*'));console.log(stream.single());// '**value'
memo()
Memoizes and returns the same Stream that always produces the same value.
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').apply(i =>i.padStart(7,'*')).memo();console.log(stream.many(2));// ['**value', '**value']
import { val } from'@fluentfixture/core';// val() returns a Stream with a static value.conststream=val('value').dump(i =>console.log(i)).apply(i =>i.padStart(7,'*'));console.log(stream.many(2));// 'values'// ['**value', '**value']