{ "_args": [ [ { "raw": "binary@^0.3.0", "scope": null, "escapedName": "binary", "name": "binary", "rawSpec": "^0.3.0", "spec": ">=0.3.0 <0.4.0", "type": "range" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/decompress-zip" ] ], "_defaultsLoaded": true, "_engineSupported": true, "_from": "binary@>=0.3.0 <0.4.0", "_id": "binary@0.3.0", "_inCache": true, "_location": "/binary", "_nodeVersion": "v0.6.11", "_npmUser": { "name": "substack", "email": "mail@substack.net" }, "_npmVersion": "1.1.19", "_phantomChildren": {}, "_requested": { "raw": "binary@^0.3.0", "scope": null, "escapedName": "binary", "name": "binary", "rawSpec": "^0.3.0", "spec": ">=0.3.0 <0.4.0", "type": "range" }, "_requiredBy": [ "/decompress-zip" ], "_resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", "_shasum": "9f60553bc5ce8c3386f3b553cff47462adecaa79", "_shrinkwrap": null, "_spec": "binary@^0.3.0", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/decompress-zip", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "bugs": { "url": "https://github.com/substack/node-binary/issues" }, "dependencies": { "buffers": "~0.1.1", "chainsaw": "~0.1.0" }, "description": "Unpack multibyte binary values from buffers", "devDependencies": { "seq": "~0.2.5", "tap": "~0.2.4" }, "directories": {}, "dist": { "shasum": "9f60553bc5ce8c3386f3b553cff47462adecaa79", "tarball": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz" }, "engine": { "node": ">=0.4.0" }, "engines": { "node": "*" }, "homepage": "https://github.com/substack/node-binary#readme", "keywords": [ "binary", "decode", "endian", "unpack", "signed", "unsigned" ], "license": "MIT", "main": "./index.js", "maintainers": [ { "name": "substack", "email": "mail@substack.net" } ], "name": "binary", "optionalDependencies": {}, "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", "repository": { "type": "git", "url": "git+ssh://git@github.com/substack/node-binary.git" }, "scripts": { "test": "tap test/*.js" }, "version": "0.3.0" }