wishthis/node_modules/fork-stream/example.js
2022-01-21 09:28:41 +01:00

16 lines
336 B
JavaScript

#!/usr/bin/env node
var ForkStream = require("./");
var fork = new ForkStream({
classifier: function classify(e, done) {
return done(null, e >= 5);
},
});
fork.a.on("data", console.log.bind(null, "a"));
fork.b.on("data", console.log.bind(null, "b"));
for (var i=0;i<20;++i) {
fork.write(Math.round(Math.random() * 10));
}