stream-flow-control
Version:
Stream Flow Control
96 lines (94 loc) • 1.66 kB
YAML
_require:
fs: fs
path: path
_customTypes:
write_file:
constructor: return fs.createWriteStream(options.file);
in:
- in
out: []
required:
methods: []
write_file:
type: write_file
_editorAttrs:
pos:
x: 650
'y': 40
options:
file: tests/manager/manager2.out
read_string:
type: Readable
_editorAttrs:
pos:
x: 50
'y': 40
pipe:
- type: FlowAll
name: route
methods:
read:
code: |-
[...Array(20)].forEach((v, k) => {
this.push(k);
});
this.push(null);
params: []
route:
type: FlowAll
_editorAttrs:
pos:
x: 250
'y': 40
pipe: []
when:
- cond: return payload % 2 !== 0;
_editorAttrs:
name: odd
dst:
- type: Transform
name: add_odd_text
- cond: return payload % 2 === 0;
_editorAttrs:
name: even
dst:
- type: Transform
name: add_even_text
add_odd_text:
type: Transform
_editorAttrs:
pos:
x: 450
'y': 40
pipe:
- type: write_file
name: write_file
methods:
transform:
code: |-
this.push(chunk+' is odd\n');
callback();
params:
- chunk
- encoding
- callback
add_even_text:
type: Transform
_editorAttrs:
pos:
x: 450
'y': 160
methods:
transform:
code: |-
this.push(chunk+' is even\n');
callback();
params:
- chunk
- encoding
- callback
pipe:
- type: write_file
name: write_file
_editorAttrs:
documentId: ttVIkCsb1qpkzIAKewFP4pia7Q3XCvjj