Skip to content

String Cleanup

These pipes are used to cleanup the given string values.

Note

These pipes are only applicable on string inputs

Trim Value Pipe

This value pipe removes all the leading and trailing whitespaces in the given string.

1
2
3
4
5
const value = '  my string\t\n';

const pipe = getValuePipe('trim');

console.log(pipe(value))

Output

'my string'
1
2
3
4
5
6
7
8
const generator = getValueGenerator('constant-value', {
    value: '  my string\t\n',
    pipes: [
        'trim'
    ]
});

console.log(generator.generate())

Output

'my string'

Tip

This example uses Constant Value Generator. You may want to check it out 😉

Single Space Value Pipe

This Value Pipe removes multiple spaces and turns them into a single one.

1
2
3
4
5
const value = 'my  string    with spaces';

const pipe = getValuePipe('single-space');

console.log(pipe(value))

Output

'my string with spaces'
1
2
3
4
5
6
7
8
const generator = getValueGenerator('constant-value', {
    value: 'my  string    with spaces',
    pipes: [
        'single-space'
    ]
});

console.log(generator.generate())

Output

'my string with spaces'

Tip

This example uses Constant Value Generator. You may want to check it out 😉