Version 1
[yaffs-website] / node_modules / fork-stream / example.js
diff --git a/node_modules/fork-stream/example.js b/node_modules/fork-stream/example.js
new file mode 100755 (executable)
index 0000000..8700191
--- /dev/null
@@ -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));
+}