The ObjectStream is a Stream that provides object-related methods.
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}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}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'}