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
  • pick()
  • join()
  • sample()
  • sort()
  • map()
  • filter()
Edit on GitHub
  1. PACKAGES
  2. @fluentfixture/core
  3. Streams

Array Stream

PreviousDate StreamNextObject Stream

Last updated 7 months ago

The ArrayStream is a that provides array-related methods.

pick()

Returns a that picks an item from the produced output.

import { list } from '@fluentfixture/core';

const stream = list([1, 2, 3]).pick();

console.log(stream.single());
// 2

join()

Returns a that merges the produced output.

Parameter
Type
Default
Description

seperator

String

''

separator

import { list } from '@fluentfixture/core';

const stream = list([1, 2, 3]).join('+');

console.log(stream.single());
// '1+2+3'

sample()

Parameter
Type
Default
Description

size

Integer

3

sample size

import { list } from '@fluentfixture/core';

const stream = list([1, 2, 3]).sample(2);

console.log(stream.single());
// [1, 2]

sort()

Parameter
Type
Default
Description

fn

Function

sort function

import { list } from '@fluentfixture/core';

const stream = list([3, 5, 4]).sort((a, b) => b - a);

console.log(stream.single());
// [5, 4, 3]

map()

Parameter
Type
Default
Description

fn

Function

map function

import { list } from '@fluentfixture/core';

const stream = list([3, 5, 4]).map(i => i.toString());

console.log(stream.single());
// ['3', '4', '5']

filter()

Parameter
Type
Default
Description

fn

Function

filter function

import { list } from '@fluentfixture/core';

const stream = list([3, 5, 4]).filter(i => i % 2 === 0);

console.log(stream.single());
// [4]

Returns an that samples the produced output.

Returns an that sorts the produced output.

Returns an that maps the produced output.

Returns an that filters the produced output.

Stream
Stream
StringStream
ArrayStream
ArrayStream
ArrayStream
ArrayStream