Permalink
Browse files

stream example

  • Loading branch information...
1 parent 8464aae commit d783aa4aa36bfd6082ca2fd5f164acc5784ffd63 @substack committed Dec 10, 2010
Showing with 31 additions and 0 deletions.
  1. +20 −0 README.markdown
  2. +11 −0 examples/stream.js
View
@@ -28,6 +28,26 @@ buf.js
$ node buf.js
{ ab: 25185, cf: 1667523942, x: 0 }
+stream.js
+---------
+
+ var Binary = require('binary');
+ var stdin = process.openStdin();
+
+ Binary(stdin)
+ .word32lu('x')
+ .word16bs('y')
+ .word16bu('z')
+ .tap(function (vars) {
+ console.dir(vars);
+ })
+ ;
+-
+ $ node examples/stream.js
+ abcdefgh
+ { x: 1684234849, y: 25958, z: 26472 }
+ ^D
+
Methods
=======
View
@@ -0,0 +1,11 @@
+var Binary = require('binary');
+var stdin = process.openStdin();
+
+Binary(stdin)
+ .word32lu('x')
+ .word16bs('y')
+ .word16bu('z')
+ .tap(function (vars) {
+ console.dir(vars);
+ })
+;

0 comments on commit d783aa4

Please sign in to comment.