The ArrayStream is a Stream that provides array-related methods.
Returns a Stream that picks an item from the produced output.
import { list } from '@fluentfixture/core';
const stream = list([1, 2, 3]).pick();
console.log(stream.single());
// 2Returns a StringStream 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'Returns an ArrayStream that samples the produced output.
| 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]Returns an ArrayStream that sorts the produced output.
| 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]Returns an ArrayStream that maps the produced output.
| 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']Returns an ArrayStream that filters the produced output.
| 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]