String Stream

The StringStream is a Stream that provides string-related methods.

trim()

Returns a StringStream that trims the produced output. (Mdn Docs)

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

const stream = text(' text ').trim();

console.log(stream.single());
// 'text'

trimStart()

Returns a StringStream that trims (from the start) the produced output. (Mdn Docs)

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

const stream = text(' text ').trimStart();

console.log(stream.single());
// 'text '

trimEnd()

Returns a StringStream that trims (from the end) the produced output. (Mdn Docs)

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

const stream = text(' text ').trimEnd();

console.log(stream.single());
// ' text'

padStart()

Returns a StringStream that add pads (from the start) to the produced output. (Mdn Docs)

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

const stream = text('text').padStart(7, '#');

console.log(stream.single());
// '###text'

padEnd()

Returns a StringStream that add pads (from the end) to the produced output. (Mdn Docs)

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

const stream = text('text').padEnd(7, '#');

console.log(stream.single());
// 'text###'

split()

Returns an ArrayStream that produces the split output. (Mdn Docs)

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

const stream = text('1,2,3')
    .split(',')
    .map(i => `#${i}`)

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

lowerCase()

Returns a StringStream that converts the produced output to the lower case. (Mdn Docs)

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

const stream = text('HELLO').lowerCase();

console.log(stream.single());
// 'hello'

upperCase()

Returns a StringStream that converts the produced output to the upper case. (Mdn Docs)

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

const stream = text('hello').upperCase();

console.log(stream.single());
// 'HELLO'

camelCase()

Returns a StringStream that converts the produced output to the camel case. (Library Docs)

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

const stream = text('hello world').camelCase();

console.log(stream.single());
// 'helloWorld'

capitalCase()

Returns a StringStream that converts the produced output to the capital case. (Library Docs)

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

const stream = text('hello world').capitalCase();

console.log(stream.single());
// 'Hello World'

constantCase()

Returns a StringStream that converts the produced output to the constant case. (Library Docs)

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

const stream = text('hello world').constantCase();

console.log(stream.single());
// 'HELLO_WORLD'

pathCase()

Returns a StringStream that converts the produced output to the path case. (Library Docs)

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

const stream = text('hello world').pathCase();

console.log(stream.single());
// 'hello/world'

dotCase()

Returns a StringStream that converts the produced output to the dot case. (Library Docs)

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

const stream = text('hello world').dotCase();

console.log(stream.single());
// 'hello.world'

headerCase()

Returns a StringStream that converts the produced output to the header case. (Library Docs)

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

const stream = text('hello world').headerCase();

console.log(stream.single());
// 'Hello-World'

paramCase()

Returns a StringStream that converts the produced output to the param case. (Library Docs)

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

const stream = text('hello world').paramCase();

console.log(stream.single());
// 'hello-world'

pascalCase()

Returns a StringStream that converts the produced output to the pascal case. (Library Docs)

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

const stream = text('hello world').pascalCase();

console.log(stream.single());
// 'HelloWorld'

snakeCase()

Returns a StringStream that converts the produced output to the snake case. (Library Docs)

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

const stream = text('hello world').snakeCase();

console.log(stream.single());
// 'hello_world'

Last updated