Skip to content

Commit

Permalink
update to new flow version
Browse files Browse the repository at this point in the history
  • Loading branch information
ottiker committed Mar 13, 2017
1 parent b9b7a8d commit 2552931
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions lib/emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@

// TODO create a suite to route flow sequences

module.exports = function (scope, state, args = {}, data, stream, next) {

/*{
seqId: data.seqId (string)
package: data.data (object)
stream: data.stream (bool)
}*/
module.exports = function (event, state, args, next) {

// call flow sequnce
let options;
if (typeof stream.pipe === "function") {
options = {objectMode: args.objectMode || stream._readableState.objectMode};
if (typeof event.output.pipe === "function") {
options = {objectMode: args.objectMode};// || stream._i._readableState.objectMode};
}

const flow = scope.flow(args.seq || data.seq, args.data || data, options, next);
flow.on('error', next);
stream.done = next;
if (flow.pipe) {
stream = stream.pipe(flow);
}
data.seq = args.seq || data.seq;
next(null, data, event.output.pipe(scope.flow(data.seq, args.data || data, options)));
};

0 comments on commit 2552931

Please sign in to comment.