-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
executable file
·46 lines (46 loc) · 4.96 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
"name": "binary",
"version": "0.3.0",
"description": "Unpack multibyte binary values from buffers",
"main": "./index.js",
"repository": {
"type": "git",
"url": "http://github.com/substack/node-binary.git"
},
"keywords": [
"binary",
"decode",
"endian",
"unpack",
"signed",
"unsigned"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"dependencies": {
"chainsaw": "~0.1.0",
"buffers": "~0.1.1"
},
"devDependencies": {
"seq": "~0.2.5",
"tap": "~0.2.4"
},
"scripts": {
"test": "tap test/*.js"
},
"license": "MIT",
"engine": {
"node": ">=0.4.0"
},
"readme": "binary\n======\n\nUnpack multibyte binary values from buffers and streams.\nYou can specify the endianness and signedness of the fields to be unpacked too.\n\nThis module is a cleaner and more complete version of\n[bufferlist](https://github.com/substack/node-bufferlist)'s binary module that\nruns on pre-allocated buffers instead of a linked list.\n\n[![build status](https://secure.travis-ci.org/substack/node-binary.png)](http://travis-ci.org/substack/node-binary)\n\nexamples\n========\n\nstream.js\n---------\n\n``` js\nvar binary = require('binary');\n\nvar ws = binary()\n .word32lu('x')\n .word16bs('y')\n .word16bu('z')\n .tap(function (vars) {\n console.dir(vars);\n })\n;\nprocess.stdin.pipe(ws);\nprocess.stdin.resume();\n```\n\noutput:\n\n```\n$ node examples/stream.js\nabcdefgh\n{ x: 1684234849, y: 25958, z: 26472 }\n^D\n```\n\nparse.js\n--------\n\n``` js\nvar buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);\n\nvar binary = require('binary');\nvar vars = binary.parse(buf)\n .word16ls('ab')\n .word32bu('cf')\n .word8('x')\n .vars\n;\nconsole.dir(vars);\n```\n\noutput:\n\n```\n{ ab: 25185, cf: 1667523942, x: 0 }\n```\n\nmethods\n=======\n\n`var binary = require('binary')`\n\nvar b = binary()\n----------------\n\nReturn a new writable stream `b` that has the chainable methods documented below\nfor buffering binary input.\n\nbinary.parse(buf)\n-----------------\n\nParse a static buffer in one pass. Returns a chainable interface with the\nmethods below plus a `vars` field to get at the variable stash as the last item\nin a chain.\n\nIn parse mode, methods will set their keys to `null` if the buffer isn't big\nenough except `buffer()` and `scan()` which read up up to the end of the buffer\nand stop.\n\nb.word{8,16,32,64}{l,b}{e,u,s}(key)\n-----------------------------------\n\nParse bytes in the buffer or stream given:\n\n* number of bits\n* endianness ( l : little, b : big ),\n* signedness ( u and e : unsigned, s : signed )\n\nThese functions won't start parsing until all previous parser functions have run\nand the data is available.\n\nThe result of the parse goes into the variable stash at `key`.\nIf `key` has dots (`.`s), it refers to a nested address. If parent container\nvalues don't exist they will be created automatically, so for instance you can\nassign into `dst.addr` and `dst.port` and the `dst` key in the variable stash\nwill be `{ addr : x, port : y }` afterwards.\n\nb.buffer(key, size)\n-------------------\n\nTake `size` bytes directly off the buffer stream, putting the resulting buffer\nslice in the variable stash at `key`. If `size` is a string, use the value at\n`vars[size]`. The key follows the same dotted address rules as the word\nfunctions.\n\nb.scan(key, buffer)\n-------------------\n\nSearch for `buffer` in the stream and store all the intervening data in the\nstash at at `key`, excluding the search buffer. If `buffer` passed as a string,\nit will be converted into a Buffer internally.\n\nFor example, to read in a line you can just do:\n\n``` js\nvar b = binary()\n .scan('line', new Buffer('\\r\\n'))\n .tap(function (vars) {\n console.log(vars.line)\n })\n;\nstream.pipe(b);\n```\n\nb.tap(cb)\n---------\n\nThe callback `cb` is provided with the variable stash from all the previous\nactions once they've all finished.\n\nYou can nest additional actions onto `this` inside the callback.\n\nb.into(key, cb)\n---------------\n\nLike `.tap()`, except all nested actions will assign into a `key` in the `vars`\nstash.\n\nb.loop(cb)\n----------\n\nLoop, each time calling `cb(end, vars)` for function `end` and the variable\nstash with `this` set to a new chain for nested parsing. The loop terminates\nonce `end` is called.\n\nb.flush()\n---------\n\nClear the variable stash entirely.\n\ninstallation\n============\n\nTo install with [npm](http://github.com/isaacs/npm):\n\n```\nnpm install binary\n```\n\nnotes\n=====\n\nThe word64 functions will only return approximations since javascript uses ieee\nfloating point for all number types. Mind the loss of precision.\n\nlicense\n=======\n\nMIT\n\n",
"readmeFilename": "README.markdown",
"bugs": {
"url": "https://github.com/substack/node-binary/issues"
},
"homepage": "https://github.com/substack/node-binary",
"_id": "binary@0.3.0",
"_from": "binary@~0.3.0"
}