Constructor
# new Pipe(pipe)
Parameters:
Name | Type | Description |
---|---|---|
pipe |
string | a pipe consists of commands whose input and output are connected with the pipe symbol |
- Since:
- 1.5.0
- Copyright:
- schukai GmbH
Throws:
TypeError
Example
import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/data/pipe.js';
let obj = {
a: {
b: {
c: {
d: "world"
}
}
}
}
console.log(new Pipe('path:a.b.c.d | toupper | prefix:Hello\\ ').run(obj));
// ↦ Hello WORLD
Methods
# run(value) → {*}
run a pipe
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
Returns:
- Type
- *
# setCallback(name, callback, context) → {Transformer}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
callback |
function | |
context |
object |
Throws:
-
-
value is not a string
- Type
- TypeError
-
-
-
value is not a function
- Type
- TypeError
-
Returns:
- Type
- Transformer