Permalink
Browse files

parse example

  • Loading branch information...
1 parent 2eb9406 commit 5876a651f13e570c0f3b7429eeebd8a79fa5de12 @substack committed Dec 13, 2010
Showing with 26 additions and 0 deletions.
  1. +16 −0 README.markdown
  2. +10 −0 examples/parse.js
View
16 README.markdown
@@ -28,6 +28,22 @@ buf.js
$ node buf.js
{ ab: 25185, cf: 1667523942, x: 0 }
+parse.js
+--------
+ var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
+
+ var Binary = require('binary');
+ var vars = Binary.parse(buf)
+ .word16ls('ab')
+ .word32bu('cf')
+ .word8('x')
+ .vars
+ ;
+ console.dir(vars);
+-
+ $ node parse.js
+ { ab: 25185, cf: 1667523942, x: 0 }
+
stream.js
---------
View
10 examples/parse.js
@@ -0,0 +1,10 @@
+var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
+
+var Binary = require('binary');
+var vars = Binary.parse(buf)
+ .word16ls('ab')
+ .word32bu('cf')
+ .word8('x')
+ .vars
+;
+console.dir(vars);

0 comments on commit 5876a65

Please sign in to comment.