X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Ffork-stream%2Fexample.js;fp=node_modules%2Ffork-stream%2Fexample.js;h=8700191edbb19b8b08cb80ac0eaa77921978a6c7;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/fork-stream/example.js b/node_modules/fork-stream/example.js new file mode 100755 index 000000000..8700191ed --- /dev/null +++ b/node_modules/fork-stream/example.js @@ -0,0 +1,16 @@ +#!/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)); +}