Pipe

Monster/Data. Pipe

Pipe class

the pipe class makes it possible to combine several processing steps.

you can call the method via the monster namespace new Monster.Data.Pipe().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/data/pipe.js';
console.log(new Monster.Data.Pipe())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/data/pipe.js';
console.log(new Pipe())
</script>

a pipe consists of commands whose input and output are connected with the pipe symbol |.

with the Pipe, processing steps can be combined. Here, the value of an object is accessed via the pathfinder (path command). the word is then converted to uppercase letters and a prefix Hello is added. the two backslash safe the space char.

let obj = {
    a: {
        b: {
            c: {
                d: "world"
            }
        }
    }
}

new Pipe('path:a.b.c.d | toupper | prefix:Hello\\ ').run(obj); // ↦ Hello WORLD

Constructor

new Pipe(pipe)

Source:
Since:
  • 1.5.0
Parameters:
Name Type Description
pipe string

a pipe consists of commands whose input and output are connected with the pipe symbol |.

Throws:
TypeError

Methods

run(value) → {*}

Source:

run a pipe

Parameters:
Name Type Description
value *
Returns:
Type
*