Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Latest commit

 

History

History
75 lines (53 loc) · 1.97 KB

File metadata and controls

75 lines (53 loc) · 1.97 KB

Object Stream

The ObjectStream is a Stream that provides object-related methods.

static()

Returns an ObjectStream that adds a property with the given value to the produced output.

Parameter Type Default Description
property String property name
value Any property value
import { int, obj, text } from '@fluentfixture/core';

const stream = obj({
    key: text('key'),
    value: int(1, 10)
});

const extendedStream = stream
    .static('id', 3);

console.log(extendedStream.single());
// {key: 'key', value: 10, id: 3}

dynamic()

Returns an ObjectStream that adds a property to the produced output with the given stream.

Parameter Type Default Description
property String property name
stream Stream property source
import { int, obj, text } from '@fluentfixture/core';

const stream = obj({
    key: text('key'),
    value: int(1, 10)
});

const extendedStream = stream
    .dynamic('id', int(1, 100));

console.log(extendedStream.single());
// {key: 'key', value: 10, id: 28}

lazy()

Returns an ObjectStream that adds a property to the produced output by using the result of the given function.

Parameter Type Default Description
property String property name
converter Function converter function
import { int, obj, text } from '@fluentfixture/core';

const stream = obj({
    key: text('key'),
    value: int(1, 10)
});

const extendedStream = stream
    .lazy('id', (v) => v.key.toUpperCase());

console.log(extendedStream.single());
// {key: 'key', value: 4, id: 'KEY'}