fluentfixture
ContributionCode of Conduct
  • Fluent Fixture
  • PACKAGES
    • @fluentfixture/core
      • Everything Is A Factory
      • Streams
        • Stream
        • Boolean Stream
        • Number Stream
        • String Stream
        • Date Stream
        • Array Stream
        • Object Stream
      • Generators
      • Live Demo
    • @fluentfixture/format
      • Structure
      • Pipe Functions
        • Built-In Pipes
        • Custom Pipes
      • How To Use
      • Error Handling
      • Live Demo
  • 🫂Contribution
  • 🐦Follow me on Twitter :)
Powered by GitBook
On this page
  • static()
  • dynamic()
  • lazy()
Edit on GitHub
  1. PACKAGES
  2. @fluentfixture/core
  3. Streams

Object Stream

PreviousArray StreamNextGenerators

Last updated 7 months ago

The ObjectStream is a that provides object-related methods.

static()

Returns an 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()

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()

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'}

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

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

Stream
ObjectStream
ObjectStream
ObjectStream