{"_id":"packet-reader","_rev":"82786","name":"packet-reader","description":"Read binary packets...","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"time":{"modified":"2021-06-03T10:26:23.000Z","created":"2013-12-31T04:09:16.941Z","1.0.0":"2019-02-20T15:41:20.604Z","0.3.1":"2017-05-12T15:23:58.577Z","0.3.0":"2016-11-30T15:47:55.564Z","0.2.1":"2016-11-30T15:10:22.335Z","0.2.0":"2014-03-14T11:15:19.125Z","0.1.0":"2014-03-14T10:51:44.888Z","0.0.0":"2013-12-31T04:09:16.941Z"},"users":{},"author":{"name":"Brian M. Carlson"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-reader.git"},"versions":{"1.0.0":{"name":"packet-reader","version":"1.0.0","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-reader.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-reader/issues"},"homepage":"https://github.com/brianc/node-packet-reader","devDependencies":{"mocha":"~1.21.5"},"gitHead":"dceac2f7da94e42b57f95f8d53577136505c8902","_id":"packet-reader@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.2","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"dist":{"shasum":"9238e5480dedabacfe1fe3f2771063f164157d74","size":3093,"noattachment":false,"key":"/packet-reader/-/packet-reader-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-1.0.0.tgz"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/packet-reader_1.0.0_1550677280490_0.16562223921335262"},"_hasShrinkwrap":false,"publish_time":1550677280604,"_cnpm_publish_time":1550677280604},"0.3.1":{"name":"packet-reader","version":"0.3.1","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-reader.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-reader/issues"},"homepage":"https://github.com/brianc/node-packet-reader","devDependencies":{"mocha":"~1.16.2"},"gitHead":"bd2e4e1c5d4cd2cea8ae387307e66f51276e28dd","_id":"packet-reader@0.3.1","_shasum":"cd62e60af8d7fea8a705ec4ff990871c46871f27","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"dist":{"shasum":"cd62e60af8d7fea8a705ec4ff990871c46871f27","size":3060,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.3.1.tgz"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/packet-reader-0.3.1.tgz_1494602636735_0.5185135649517179"},"publish_time":1494602638577,"_hasShrinkwrap":false,"_cnpm_publish_time":1494602638577},"0.3.0":{"name":"packet-reader","version":"0.3.0","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-reader.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-reader/issues"},"homepage":"https://github.com/brianc/node-packet-reader","devDependencies":{"mocha":"~1.16.2"},"gitHead":"cb5096cc60e2474f875b7b90e2f6dd78700e1f33","_id":"packet-reader@0.3.0","_shasum":"2b304b2c15b4a64276ce46d837692b054673311c","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"dist":{"shasum":"2b304b2c15b4a64276ce46d837692b054673311c","size":2927,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.3.0.tgz"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/packet-reader-0.3.0.tgz_1480520873617_0.7261112460400909"},"publish_time":1480520875564,"_cnpm_publish_time":1480520875564,"_hasShrinkwrap":false},"0.2.1":{"name":"packet-reader","version":"0.2.1","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-reader.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-reader/issues"},"homepage":"https://github.com/brianc/node-packet-reader","devDependencies":{"mocha":"~1.16.2"},"gitHead":"772d08619cf29d7304e918fcec19a6a3f19fbca3","_id":"packet-reader@0.2.1","_shasum":"52f625d6ef155887e8b3681e82729b8afa295191","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"dist":{"shasum":"52f625d6ef155887e8b3681e82729b8afa295191","size":2917,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.2.1.tgz"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/packet-reader-0.2.1.tgz_1480518620373_0.31471323873847723"},"publish_time":1480518622335,"_cnpm_publish_time":1480518622335,"_hasShrinkwrap":false},"0.2.0":{"name":"packet-reader","version":"0.2.0","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-parser.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-parser/issues"},"homepage":"https://github.com/brianc/node-packet-parser","devDependencies":{"mocha":"~1.16.2"},"_id":"packet-reader@0.2.0","dist":{"shasum":"819df4d010b82d5ea5671f8a1a3acf039bcd7700","size":1585,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.2.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"publish_time":1394795719125,"_cnpm_publish_time":1394795719125,"_hasShrinkwrap":false},"0.1.0":{"name":"packet-reader","version":"0.1.0","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-parser.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-parser/issues"},"homepage":"https://github.com/brianc/node-packet-parser","devDependencies":{"mocha":"~1.16.2"},"_id":"packet-reader@0.1.0","dist":{"shasum":"54848b9ace4d41459f535675bac213737baa7e2b","size":1423,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.1.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"publish_time":1394794304888,"_cnpm_publish_time":1394794304888,"_hasShrinkwrap":false},"0.0.0":{"name":"packet-reader","version":"0.0.0","description":"Read binary packets...","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/brianc/node-packet-parser.git"},"author":{"name":"Brian M. Carlson"},"license":"MIT","bugs":{"url":"https://github.com/brianc/node-packet-parser/issues"},"homepage":"https://github.com/brianc/node-packet-parser","devDependencies":{"mocha":"~1.16.2"},"_id":"packet-reader@0.0.0","dist":{"shasum":"2b0b6e0110be1bce12ab872e997ed31b060131ed","size":1351,"noattachment":false,"key":"/packet-reader/-/packet-reader-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/packet-reader/download/packet-reader-0.0.0.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"maintainers":[{"name":"brianc","email":"brian.m.carlson@gmail.com"}],"publish_time":1388462956941,"_cnpm_publish_time":1388462956941,"_hasShrinkwrap":false}},"readme":"node-packet-reader\n==================\n\nHandy little well tested module for reading length-prefixed binary packets.\n\nSince buffers come off a socket in randomly sized chunks you can't expect them to cleanly\nbreak on packet boundaries.  This module allows you to push buffers in and read\nfull packets out the other side, so you can get to parsing right away and not have\nto manage concatenating partial buffers and searching through them for packets.\n\n## install\n\n` $ npm install packet-reader `\n\n## example\n\n```js\nvar Reader = require('packet-reader')\n\nvar reader = new Reader()\n//assuming you have a socket emitting `data` events\nsocket.on('data', function(buffer) {\n  reader.addChunk(buffer)\n  var packet = reader.read()\n  while(packet) {\n    //do something with fully parsed packet\n  }\n})\n```\n\n\nhere's a more full featured example:\n\nlet's assume our \"packet\" for our protocol is 32-bit Big Endian length-prefixed strings\nso a \"hello world\" packet would look something like [length, string]\n`[0, 0, 0 0x0B, h, e, l, l, o, w, o, r, l, d]`\n\n```js\nvar Transform = require('stream').Transform\nvar Reader = require('packet-reader')\nvar reader = new Reader()\nvar parser = new Transform()\nparser._transform = function(chunk, encoding, cb) {\n  reader.addChunk(chunk)\n  var packet = reader.read()\n  while(packet) {\n    this.push(packet.toString('utf8'))\n    packet = reader.read()\n  }\n  cb()\n}\n\nvar server = net.createServer(function(socket) {\n  socket.pipe(parser).pipe(stdout)\n})\n\n```\n\nThere are a few config options for setting optional pre-length padding byte.  Read the tests for details.\n\n## License\n\nMIT\n\nCopyright 2015 Brian M. Carlson\nAll rights reserved.\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n","_attachments":{},"homepage":"https://github.com/brianc/node-packet-reader","bugs":{"url":"https://github.com/brianc/node-packet-reader/issues"},"license":"MIT"}