let pipeline = new Pipeline();
let firstLayer = {
request: function(input) {
// cannot handle the request
if (input.value !== 'foo') {
input.next();
}
input.resolve('foo');
},
response: function(value) {
return 'the ' + value;
}
};
let secondLayer = {
request: function(input) {
// handle the request
input.resolve('response');
}
};
pipeline.run('request').then(function(result) {
// result comes from the __second__ layer here
// after being processed in the __first__ layer
// having the value 'the response'
});
pipeline.run('foo').then(function(result) {
// result now comes from the __first__ layer,
// and 'the foo' is the returned value
});
-
Notifications
You must be signed in to change notification settings - Fork 0
darlanalves/pipeline
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A bidirectional pipeline to chain data processing (similar to streams)
Resources
Stars
Watchers
Forks
Packages 0
No packages published