{"_id":"xfer","_rev":"20-b81be0182a45c1255bd1b5a8868c4d14","name":"xfer","description":"A simple, general purpose, TLV-like binary protocol","dist-tags":{"latest":"0.2.1"},"versions":{"0.0.1":{"name":"xfer","version":"0.0.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/mscdex/xfer.git"},"_id":"xfer@0.0.1","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.8","directories":{},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"508029422327a0d749240eac0c7aeb38066236a6","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.0.1.tgz","integrity":"sha512-gQpxIvBtYXuSKe32uLQikNmqDMkCrfQDHr6UcFwiknC+YpzdbkcgwwaIBxhMJ3AXLeNhN1yEFXg2iXZ4DIAaoQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFHwXYgIL3XhNETFqPmaph0oqWJe5jPjXt8N/Z209Q/BAiEAla5zgCosnanEvgifU+uWzJLBAjIXq5HCt3kkEVG9ybw="}]},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.2":{"name":"xfer","version":"0.0.2","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/mscdex/xfer.git"},"_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"_id":"xfer@0.0.2","dependencies":{},"devDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-beta-4","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"bcbc6ebb669aac6ef6f228cb098aa7ce4d71f753","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.0.2.tgz","integrity":"sha512-/rLwFb99fIf6INPyA1PELzTifDU9BS6PR5M9qZdiuFJZN6tEKvUOxiWodCMqZQSSowLAPuV4afhavtnXnBgbpA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvByaXlYoiuLtGRcdy9ijNo9T+riTTJTO1nh1cHzSjSwIhANIQifDzns05QkCepT5EzYGUUQxpXKGe3epxzfu5E+mr"}]},"scripts":{},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that provides reading and writing of simple TLV (Type-Length-Value) tuples.\n\nThis module allows configurable type and length field sizes and requires that both sender and receiver agree on a type and length size.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.4.0 or newer\n\n\nExample\n=======\n\n        var net = require('net'), Xfer = require('xfer');\n\n        var TYPE_SIZE = 1, // in bytes, 0 to 255\n            LEN_SIZE = 2; // in bytes, 2 bytes == maximum payload size is 65535 bytes\n\n        var server = net.createServer(function(client) {\n          client.xfer = new Xfer(TYPE_SIZE, LEN_SIZE, client);\n          client.xfer.write(0x20, 'My cool little message! :-)');\n          client.xfer.write(0x01, new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));\n        });\n        server.listen(8118);\n\n        process.nextTick(function() {\n          var client = net.createConnection(8118);\n          client.xfer = new Xfer(TYPE_SIZE, LEN_SIZE, client);\n          client.xfer.on(0x20, function(data) {\n            console.error('Got message 0x20: ' + data.toString());\n          });\n          client.xfer.on(0x01, function(data) {\n            console.error('Got message 0x01: ' + require('util').inspect(data));\n            client.end();\n            server.close();\n          });\n        });\n\n        // output:\n        //    Got message 0x20: My cool little message! :-)\n        //    Got message 0x01: <Buffer 01 02 03 04 05 06 07 08 09 0a>\n","maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.3":{"name":"xfer","version":"0.0.3","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/mscdex/xfer.git"},"_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"_id":"xfer@0.0.3","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.9","_nodeVersion":"v0.6.13","_defaultsLoaded":true,"dist":{"shasum":"9f572f325676e5b43b52a5898f260a30fc7fe373","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.0.3.tgz","integrity":"sha512-OSlfNqJjifvEelS7W8yv27zgF5TEbbOI7X1dp9CWCjTjsU3ONoakxPKg/OoBObYFoIb8KRbuwQsYTnhh6+OPiA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDaLRJzh/BGWhnUaB/jRIetJOQEVVYnAY3V7irDmSrXiwIhAO7mq1bRbOBggg14Pr78bqwA9EZKWJTtLHz5f62lTOoo"}]},"scripts":{},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that provides reading and writing of simple TLV (Type-Length-Value) tuples.\n\nThis module allows configurable type and length field sizes and requires that both sender and receiver agree on a type and length size.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.4.0 or newer\n\n\nExample\n=======\n\n        var net = require('net'), Xfer = require('xfer');\n\n        var TYPE_SIZE = 1, // in bytes, 0 to 255\n            LEN_SIZE = 2; // in bytes, 2 bytes == maximum payload size is 65535 bytes\n\n        var server = net.createServer(function(client) {\n          client.xfer = new Xfer(TYPE_SIZE, LEN_SIZE, client);\n          client.xfer.write(0x20, 'My cool little message! :-)');\n          client.xfer.write(0x01, new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));\n        });\n        server.listen(8118, function() {\n          var client = net.createConnection(8118);\n          client.xfer = new Xfer(TYPE_SIZE, LEN_SIZE, client);\n          client.xfer.on(0x20, function(data) {\n            console.error('Got message 0x20: ' + data.toString());\n          });\n          client.xfer.on(0x01, function(data) {\n            console.error('Got message 0x01: ' + require('util').inspect(data));\n            client.end();\n            server.close();\n          });\n        });\n\n        // output:\n        //    Got message 0x20: My cool little message! :-)\n        //    Got message 0x01: <Buffer 01 02 03 04 05 06 07 08 09 0a>\n","maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.1.0":{"name":"xfer","version":"0.1.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/mscdex/xfer.git"},"_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"_id":"xfer@0.1.0","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.9","_nodeVersion":"v0.6.13","_defaultsLoaded":true,"dist":{"shasum":"011c9892adef61b4d2b9341496b992b72d4afc34","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.1.0.tgz","integrity":"sha512-sGEXo83V3vBdU/qLCfSiCnkHv9pt0oQYfcLs/aOrVwBSb38SDsD3yyTMavRhvoZT84UtTzQysuroxe9NVto6GA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGV5Ho2pGqjsgqWTDLbKFZuAmtcRwFil2RXctzKk8FUeAiEAhbTCqO4xQbfiNZGASsgN+rSBXRvdGKNsVFZWpQAykN4="}]},"scripts":{},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that provides reading and writing of simple TLV (Type-Length-Value) tuples.\n\nThis module allows configurable type and length field sizes and requires that both sender and receiver agree on a type and length size.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.4.0 or newer\n\n\nExample\n=======\n```javascript\n  var net = require('net'), inspect = require('util').inspect,\n      Xfer = require('xfer');\n\n  var TYPE_LEN = 1, // in bytes, 0 to 255\n      SIZE_LEN = 4, // in bytes, 4 bytes == maximum payload size is 4,294,967,295 bytes\n      BUFFERING = true;\n\n  var server = net.createServer(function(client) {\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      writeOnly: true\n    });\n\n    var mediumBuf = new Buffer(300000); // 300kb message\n    for (var i=0; i<300000; ++i)\n      mediumBuf[i] = i;\n\n    client.xfer.write(0x20, 'My cool little message! :-)');\n    client.xfer.write(0x01, mediumBuf);\n  });\n  server.listen(8118, function() {\n    var client = net.createConnection(8118);\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      buffer: BUFFERING\n    });\n    client.xfer.on(0x20, function(source, len) {\n      if (BUFFERING)\n        console.error('Got buffered message 0x20 (' + len + ' bytes): ' + source.toString());\n      else {\n        source.setEncoding('ascii');\n        console.error('Got streaming message 0x20 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x20 chunk (' + Buffer.byteLength(data) + ' bytes): ' + data);\n        });\n        source.on('end', function() {\n          console.error('End of message 0x20');\n        });\n      }\n    });\n    client.xfer.on(0x01, function(source, len) {\n      if (BUFFERING) {\n        console.error('Got buffered message 0x01 (' + len + ' bytes): ' + inspect(source));\n        client.end();\n        server.close();\n      } else {\n        console.error('Got streaming message 0x01 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x01 chunk (' + data.length + ' bytes): ' + inspect(data));\n        });\n        source.on('end', function() {\n          console.error('End of message 0x01');\n          client.end();\n          server.close();\n        });\n      }\n    });\n  });\n\n  /* example output with buffering enabled:\n        Got buffered message 0x20 (27 bytes): My cool little message! :-)\n        Got buffered message 0x01 (300000 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09\n        0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24\n        25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n\n    example output with buffering disabled:\n        Got message 0x20 (27 bytes)\n        Message 0x20 chunk (27 bytes): My cool little message! :-)\n        End of message 0x20\n        Got message 0x01 (300000 bytes)\n        Message 0x01 chunk (10215 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09 0a 0b 0c\n         0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 2\n        7 28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n        Message 0x01 chunk (45260 bytes): <Buffer e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3\n         f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0\n        e 0f 10 11 12 13 14 15 16 17 18 19 ...>\n        Message 0x01 chunk (37960 bytes): <Buffer b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf\n         c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d\n        a db dc dd de df e0 e1 e2 e3 e4 e5 ...>\n        Message 0x01 chunk (37960 bytes): <Buffer fb fc fd fe ff 00 01 02 03 04 05 06 07\n         08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 2\n        2 23 24 25 26 27 28 29 2a 2b 2c 2d ...>\n        Message 0x01 chunk (42340 bytes): <Buffer 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f\n         50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6\n        a 6b 6c 6d 6e 6f 70 71 72 73 74 75 ...>\n        Message 0x01 chunk (30660 bytes): <Buffer a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3\n         b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd c\n        e cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 ...>\n        Message 0x01 chunk (37960 bytes): <Buffer 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77\n         78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 9\n        2 93 94 95 96 97 98 99 9a 9b 9c 9d ...>\n        Message 0x01 chunk (37960 bytes): <Buffer b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf\n         c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d\n        a db dc dd de df e0 e1 e2 e3 e4 e5 ...>\n        Message 0x01 chunk (19685 bytes): <Buffer fb fc fd fe ff 00 01 02 03 04 05 06 07\n         08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 2\n        2 23 24 25 26 27 28 29 2a 2b 2c 2d ...>\n        End of message 0x01\n  */\n```\n\n\nAPI\n===\n\nEvents\n------\n\nTwo types of events are emitted from an Xfer instance: integer events and a special \"catch-all\" event.\n\n * Integer events represent incoming TLV tuples where the integer is the type\n\n * A 'message' event is emitted for every incoming TLV tuple\n\nInteger events are passed two values (*\\<Buffer/Stream\\>* source, *\\<Integer\\>* size) and the 'message' event is passed an additional argument (*\\<Integer\\>* type) before the source and size arguments. The source argument is a (readable only) stream only if 'buffer' was set to `false` in the configuration object passed to the constructor. The size value refers to the total size of the data in the source.\n\nMethods\n-------\n\n * *constructor* (*\\<Object\\>* config) - Available configuration properties include:\n\n    * *\\<Integer\\>* typeLen - The number of bytes to use for the type field (default: 1)\n\n    * *\\<Integer\\>* sizeLen - The number of bytes to use for the size/length field (default: 2)\n\n    * *\\<Stream\\>* stream - A Stream object to use for reading/writing TLV data from/to\n\n    * *\\<Boolean\\>* writeOnly - Do not interpret incoming data on the stream as TLV data (default: false)\n\n    * *\\<Boolean\\>* buffer - Buffer incoming value data? (default: true)\n\n * **write** (*\\<Integer\\>* type, *\\<Buffer/String\\>* data) - Writes the given information as a TLV tuple to the stream\n","maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.1.1":{"name":"xfer","version":"0.1.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/xfer.git"},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that provides reading and writing of simple TLV (Type-Length-Value) tuples.\n\nThis module allows configurable type and length field sizes and requires that both sender and receiver agree on a type and length size.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.4.0 or newer\n\n\nExample\n=======\n```javascript\n  var net = require('net'), inspect = require('util').inspect,\n      Xfer = require('xfer');\n\n  var TYPE_LEN = 1, // in bytes, 0 to 255\n      SIZE_LEN = 4, // in bytes, 4 bytes == maximum payload size is 4,294,967,295 bytes\n      BUFFERING = true;\n\n  var server = net.createServer(function(client) {\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      writeOnly: true\n    });\n\n    var mediumBuf = new Buffer(300000); // 300kb message\n    for (var i=0; i<300000; ++i)\n      mediumBuf[i] = i % 256;\n\n    client.xfer.write(0x20, 'My cool little message! :-)');\n    client.xfer.write(0x01, mediumBuf);\n  });\n  server.listen(8118, function() {\n    var client = net.createConnection(8118);\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      buffer: BUFFERING\n    });\n    client.xfer.on(0x20, function(source, len) {\n      if (BUFFERING)\n        console.error('Got buffered message 0x20 (' + len + ' bytes): ' + source.toString());\n      else {\n        source.setEncoding('ascii');\n        console.error('Got streaming message 0x20 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x20 chunk (' + Buffer.byteLength(data) + ' bytes): ' + data);\n        });\n        source.on('end', function() {\n          console.error('End of message 0x20');\n        });\n      }\n    });\n    client.xfer.on(0x01, function(source, len) {\n      if (BUFFERING) {\n        console.error('Got buffered message 0x01 (' + len + ' bytes): ' + inspect(source));\n        client.end();\n        server.close();\n      } else {\n        console.error('Got streaming message 0x01 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x01 chunk (' + data.length + ' bytes): ' + inspect(data));\n        });\n        source.on('end', function() {\n          console.error('End of message 0x01');\n          client.end();\n          server.close();\n        });\n      }\n    });\n  });\n\n  /* example output with buffering enabled:\n        Got buffered message 0x20 (27 bytes): My cool little message! :-)\n        Got buffered message 0x01 (300000 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09\n        0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24\n        25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n\n    example output with buffering disabled:\n        Got message 0x20 (27 bytes)\n        Message 0x20 chunk (27 bytes): My cool little message! :-)\n        End of message 0x20\n        Got message 0x01 (300000 bytes)\n        Message 0x01 chunk (10215 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09 0a 0b 0c\n        0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n        Message 0x01 chunk (27740 bytes): <Buffer e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3\n        f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e\n        0f 10 11 12 13 14 15 16 17 18 19 ...>\n        Message 0x01 chunk (20440 bytes): <Buffer 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f\n        50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a\n        6b 6c 6d 6e 6f 70 71 72 73 74 75 ...>\n        Message 0x01 chunk (35040 bytes): <Buffer 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42\n        43 44 45 46 47 48 49 4a 4b 4c 4d ...>\n        Message 0x01 chunk (35040 bytes): <Buffer fb fc fd fe ff 00 01 02 03 04 05 06 07\n        08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22\n        23 24 25 26 27 28 29 2a 2b 2c 2d ...>\n        Message 0x01 chunk (35040 bytes): <Buffer db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7\n        e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02\n        03 04 05 06 07 08 09 0a 0b 0c 0d ...>\n        Message 0x01 chunk (45456 bytes): <Buffer bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7\n        c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2\n        e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ...>\n        Message 0x01 chunk (36304 bytes): <Buffer 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57\n        58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72\n        73 74 75 76 77 78 79 7a 7b 7c 7d ...>\n        Message 0x01 chunk (32120 bytes): <Buffer 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42\n        43 44 45 46 47 48 49 4a 4b 4c 4d ...>\n        Message 0x01 chunk (22605 bytes): <Buffer 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f\n        a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba\n        bb bc bd be bf c0 c1 c2 c3 c4 c5 ...>\n        End of message 0x01\n  */\n```\n\n\nAPI\n===\n\nEvents\n------\n\nTwo types of events are emitted from an Xfer instance: integer events and a special \"catch-all\" event.\n\n * Integer events represent incoming TLV tuples where the integer is the type\n\n * A 'message' event is emitted for every incoming TLV tuple\n\nInteger events are passed two values (*\\<Buffer/Stream\\>* source, *\\<Integer\\>* size) and the 'message' event is passed an additional argument (*\\<Integer\\>* type) before the source and size arguments. The source argument is a (readable only) stream only if 'buffer' was set to `false` in the configuration object passed to the constructor. The size value refers to the total size of the data in the source.\n\nMethods\n-------\n\n * *constructor* (*\\<Object\\>* config) - Available configuration properties include:\n\n    * *\\<Integer\\>* typeLen - The number of bytes to use for the type field (default: 1)\n\n    * *\\<Integer\\>* sizeLen - The number of bytes to use for the size/length field (default: 2)\n\n    * *\\<Stream\\>* stream - A Stream object to use for reading/writing TLV data from/to\n\n    * *\\<Boolean\\>* writeOnly - Do not interpret incoming data on the stream as TLV data (default: false)\n\n    * *\\<Boolean\\>* buffer - Buffer incoming value data? (default: true)\n\n * **write** (*\\<Integer\\>* type, *\\<Buffer/String\\>* data) - (_void_) - Writes the given information as a TLV tuple to the stream\n\n * **pause** () - (_void_) - Pauses the underlying stream\n \n * **resume** () - (_void_) - Resumes the underlying stream\n","_id":"xfer@0.1.1","dist":{"shasum":"140fd0fb791d09bc131ee62c84e915c738f72e34","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.1.1.tgz","integrity":"sha512-I8LkrktH15oHOPuTDa++eeuMkYgq7xGNSbpRbyQCMvdgvU7Gbn/qSINzYfqJXN8oWw7wEovgSSrjut12VLQIzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsTirPuRfidU2h0tZ9KAOAF2o8Qr37Fopsp+rKsURc7AIgLZ9GCwO/TdEGSI4zQ1qpilBbIdKRMcj0WCLxti/hSfY="}]},"scripts":{},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.1.2":{"name":"xfer","version":"0.1.2","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Simple binary TLV transport","main":"./xfer","engines":{"node":">=0.4.0"},"keywords":["binary","transfer","tlv"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/xfer.git"},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that provides reading and writing of simple TLV (Type-Length-Value) tuples.\n\nThis module allows configurable type and length field sizes and requires that both sender and receiver agree on a type and length size.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.4.0 or newer\n\n\nExample\n=======\n```javascript\n  var net = require('net'), inspect = require('util').inspect,\n      Xfer = require('xfer');\n\n  var TYPE_LEN = 1, // in bytes, 0 to 255\n      SIZE_LEN = 4, // in bytes, 4 bytes == maximum payload size is 4,294,967,295 bytes\n      BUFFERING = true;\n\n  var server = net.createServer(function(client) {\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      writeOnly: true\n    });\n\n    var mediumBuf = new Buffer(300000); // 300kb message\n    for (var i=0; i<300000; ++i)\n      mediumBuf[i] = i % 256;\n\n    client.xfer.write(0x20, 'My cool little message! :-)');\n    client.xfer.write(0x01, mediumBuf);\n  });\n  server.listen(8118, function() {\n    var client = net.createConnection(8118);\n    client.xfer = new Xfer({\n      typeLen: TYPE_LEN,\n      sizeLen: SIZE_LEN,\n      stream: client,\n      buffer: BUFFERING\n    });\n    client.xfer.on(0x20, function(source, len) {\n      if (BUFFERING)\n        console.error('Got buffered message 0x20 (' + len + ' bytes): ' + source.toString());\n      else {\n        source.setEncoding('ascii');\n        console.error('Got streaming message 0x20 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x20 chunk (' + Buffer.byteLength(data) + ' bytes): ' + data);\n        });\n        source.on('end', function() {\n          console.error('End of message 0x20');\n        });\n      }\n    });\n    client.xfer.on(0x01, function(source, len) {\n      if (BUFFERING) {\n        console.error('Got buffered message 0x01 (' + len + ' bytes): ' + inspect(source));\n        client.end();\n        server.close();\n      } else {\n        console.error('Got streaming message 0x01 (' + len + ' bytes)');\n        source.on('data', function(data) {\n          console.error('Message 0x01 chunk (' + data.length + ' bytes): ' + inspect(data));\n        });\n        source.on('end', function() {\n          console.error('End of message 0x01');\n          client.end();\n          server.close();\n        });\n      }\n    });\n  });\n\n  /* example output with buffering enabled:\n        Got buffered message 0x20 (27 bytes): My cool little message! :-)\n        Got buffered message 0x01 (300000 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09\n        0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24\n        25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n\n    example output with buffering disabled:\n        Got message 0x20 (27 bytes)\n        Message 0x20 chunk (27 bytes): My cool little message! :-)\n        End of message 0x20\n        Got message 0x01 (300000 bytes)\n        Message 0x01 chunk (10215 bytes): <Buffer 00 01 02 03 04 05 06 07 08 09 0a 0b 0c\n        0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 ...>\n        Message 0x01 chunk (27740 bytes): <Buffer e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3\n        f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e\n        0f 10 11 12 13 14 15 16 17 18 19 ...>\n        Message 0x01 chunk (20440 bytes): <Buffer 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f\n        50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a\n        6b 6c 6d 6e 6f 70 71 72 73 74 75 ...>\n        Message 0x01 chunk (35040 bytes): <Buffer 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42\n        43 44 45 46 47 48 49 4a 4b 4c 4d ...>\n        Message 0x01 chunk (35040 bytes): <Buffer fb fc fd fe ff 00 01 02 03 04 05 06 07\n        08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22\n        23 24 25 26 27 28 29 2a 2b 2c 2d ...>\n        Message 0x01 chunk (35040 bytes): <Buffer db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7\n        e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02\n        03 04 05 06 07 08 09 0a 0b 0c 0d ...>\n        Message 0x01 chunk (45456 bytes): <Buffer bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7\n        c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2\n        e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ...>\n        Message 0x01 chunk (36304 bytes): <Buffer 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57\n        58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72\n        73 74 75 76 77 78 79 7a 7b 7c 7d ...>\n        Message 0x01 chunk (32120 bytes): <Buffer 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27\n        28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42\n        43 44 45 46 47 48 49 4a 4b 4c 4d ...>\n        Message 0x01 chunk (22605 bytes): <Buffer 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f\n        a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba\n        bb bc bd be bf c0 c1 c2 c3 c4 c5 ...>\n        End of message 0x01\n  */\n```\n\n\nAPI\n===\n\nEvents\n------\n\nTwo types of events are emitted from an Xfer instance: integer events and a special \"catch-all\" event.\n\n * Integer events represent incoming TLV tuples where the integer is the type\n\n * A 'message' event is emitted for every incoming TLV tuple\n\nInteger events are passed two values (*\\<Buffer/Stream\\>* source, *\\<Integer\\>* size) and the 'message' event is passed an additional argument (*\\<Integer\\>* type) before the source and size arguments. The source argument is a (readable only) stream only if 'buffer' was set to `false` in the configuration object passed to the constructor. The size value refers to the total size of the data in the source.\n\nMethods\n-------\n\n * *constructor* (*\\<Object\\>* config) - Available configuration properties include:\n\n    * *\\<Integer\\>* typeLen - The number of bytes to use for the type field (default: 1)\n\n    * *\\<Integer\\>* sizeLen - The number of bytes to use for the size/length field (default: 2)\n\n    * *\\<Stream\\>* stream - A Stream object to use for reading/writing TLV data from/to\n\n    * *\\<Boolean\\>* writeOnly - Do not interpret incoming data on the stream as TLV data (default: false)\n\n    * *\\<Boolean\\>* buffer - Buffer incoming value data? (default: true)\n\n * **write** (*\\<Integer\\>* type, *\\<Buffer/String\\>* data) - (_void_) - Writes the given information as a TLV tuple to the stream\n\n * **pause** () - (_void_) - Pauses the underlying stream\n \n * **resume** () - (_void_) - Resumes the underlying stream\n","_id":"xfer@0.1.2","dist":{"shasum":"53b1c5185ff73b289ec8da21188ebd0c4f1b5236","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.1.2.tgz","integrity":"sha512-1oHVZEX2eWiTdAmraOEw5qxBmwnw3Kh3hC8Mor8jWRnSu/JBQklCYacgmultI9rr7Q3j46X7JeVMhKMUyesaVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrbywk3HTHuO07zkhz/vTOS0qtZOZEKH7a4BgzqiiB9gIhALOPP1+lvfnLBvlH2NDHrzLrwqKCxKOsF0iNHvNafh/h"}]},"scripts":{},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.2.0":{"name":"xfer","version":"0.2.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"A simple, general purpose, TLV-like binary protocol","main":"./xfer","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["binary","protocol","tlv","generic","multipurpose","simple","messaging"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/xfer.git"},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that reads and writes binary-compatible messages using a simple TLV-like protocol.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n=======\n\n    npm install xfer\n\n\nExample\n=======\n```javascript\n  var net = require('net'),\n      inspect = require('util').inspect,\n      Xfer = require('./xfer');\n\n  function makeDisplay(role, kind) {\n    return function(arg1, arg2) {\n      var type, stream;\n      if (kind === true) {\n        type = arg1;\n        stream = arg2;\n      } else {\n        type = kind;\n        stream = arg1;\n      }\n      if (!stream)\n        console.log('[' + role + '] Type: ' + type + ', Data: (none)');\n      else {\n        var s = '';\n        stream.on('data', function(d) { s += d; })\n              .on('end', function() {\n                console.log('[' + role + '] Type: ' + type + ', Data: ' + inspect(s));\n              });\n      }\n    };\n  }\n\n  net.createServer(function(client) {\n    this.close();\n    client.xfer = new Xfer();\n    client.pipe(client.xfer).pipe(client);\n\n    client.xfer.on('*', makeDisplay('SERVER', true));\n\n    client.xfer.send(0x01, 'Node.js rules! :-)');\n    client.xfer.send(0x05);\n  }).listen(8118, function() {\n    var client = net.createConnection(8118);\n    client.xfer = new Xfer();\n    client.pipe(client.xfer).pipe(client);\n\n    client.xfer.on(0x01, makeDisplay('CLIENT', 0x01))\n               .on(0x05, makeDisplay('CLIENT', 0x05));\n    client.on('connect', function() {\n      client.xfer.send(0xFF, 'I am caught by the catch-all event!');\n      client.end();\n    });\n  });\n\n  // output:\n  //\n  // [CLIENT] Type: 5, Data: (none)\n  // [CLIENT] Type: 1, Data: 'Node.js rules! :-)'\n  // [SERVER] Type: 255, Data: 'I am caught by the catch-all event!'\n```\n\n\nAPI\n===\n\n_Xfer_ is a _Duplex_ stream\n\nXfer Events\n-----------\n\nTwo types of events are emitted from an Xfer instance: integer (type) events and a special catch-all event ('*').\n\nInteger (type) events are passed a Readable stream object if there was data with the message. The catch-all ('*') event is passed an additional argument (< _integer_ > type) before the stream object.\n\n\nXfer Methods\n------------\n\n * *constructor* ([< _object_ >config]) - Creates and returns a new Xfer instance with the following valid `config` settings:\n\n    * **highWaterMark** - _integer_ - The high water mark (in bytes) used for backpressure handling for this Xfer instance (default: 128KB)\n\n    * **streamHWM** - _integer_ - The high water mark (in bytes) used for the data streams for inbound messages (default: `highWaterMark` value from above)\n\n * **send** (< _integer_ >type[, < _mixed_ >data]) - _boolean_ - Writes the message to the Readable stream portion of the Xfer instance. If provided, `data` can be either a Buffer or string. The return value indicates whether or not more sends should be performed.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/xfer/issues"},"_id":"xfer@0.2.0","dist":{"shasum":"c9a6caa8228d3e28ee49d287c6f218bfcb514eda","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.2.0.tgz","integrity":"sha512-msEjI1RUbtXWcS66Vyxp9xARiUD5anDk0VWGXubZ0qI2rqABuOySU1LFRwhUCpEcIGzxfhDQSUNODFBGgCmyng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEsvLkrdVB7OvrmTWPq5Sascx/pljED/b93n0yjGLWJDAiEAk6tvj47dHANk3Yt/COReft6eR3/HzTPpDWCxzz3ccXM="}]},"_from":"https://github.com/mscdex/xfer/tarball/v0.2.0","_resolved":"https://github.com/mscdex/xfer/tarball/v0.2.0","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.2.1":{"name":"xfer","version":"0.2.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"A simple, general purpose, TLV-like binary protocol","main":"./lib/main","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["binary","protocol","tlv","generic","multipurpose","simple","messaging"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/xfer/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/xfer.git"},"readme":"Description\n===========\n\nxfer is a module for [node.js](http://nodejs.org/) that reads and writes binary-compatible messages using a simple TLV-like protocol.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n=======\n\n    npm install xfer\n\n\nExample\n=======\n```javascript\n  var net = require('net'),\n      inspect = require('util').inspect,\n      Xfer = require('./xfer');\n\n  function makeDisplay(role, kind) {\n    return function(arg1, arg2) {\n      var type, stream;\n      if (kind === true) {\n        type = arg1;\n        stream = arg2;\n      } else {\n        type = kind;\n        stream = arg1;\n      }\n      if (!stream)\n        console.log('[' + role + '] Type: ' + type + ', Data: (none)');\n      else {\n        var s = '';\n        stream.on('data', function(d) { s += d; })\n              .on('end', function() {\n                console.log('[' + role + '] Type: ' + type + ', Data: ' + inspect(s));\n              });\n      }\n    };\n  }\n\n  net.createServer(function(client) {\n    this.close();\n    client.xfer = new Xfer();\n    client.pipe(client.xfer).pipe(client);\n\n    client.xfer.on('*', makeDisplay('SERVER', true));\n\n    client.xfer.send(0x01, 'Node.js rules! :-)');\n    client.xfer.send(0x05);\n  }).listen(8118, function() {\n    var client = net.createConnection(8118);\n    client.xfer = new Xfer();\n    client.pipe(client.xfer).pipe(client);\n\n    client.xfer.on(0x01, makeDisplay('CLIENT', 0x01))\n               .on(0x05, makeDisplay('CLIENT', 0x05));\n    client.on('connect', function() {\n      client.xfer.send(0xFF, 'I am caught by the catch-all event!');\n      client.end();\n    });\n  });\n\n  // output:\n  //\n  // [CLIENT] Type: 5, Data: (none)\n  // [CLIENT] Type: 1, Data: 'Node.js rules! :-)'\n  // [SERVER] Type: 255, Data: 'I am caught by the catch-all event!'\n```\n\n\nAPI\n===\n\n_Xfer_ is a _Duplex_ stream\n\nXfer Events\n-----------\n\nTwo types of events are emitted from an Xfer instance: integer (type) events and a special catch-all event ('*').\n\nInteger (type) events are passed a Readable stream object if there was data with the message. The catch-all ('*') event is passed an additional argument (< _integer_ > type) before the stream object.\n\n\nXfer Methods\n------------\n\n * *constructor* ([< _object_ >config]) - Creates and returns a new Xfer instance with the following valid `config` settings:\n\n    * **highWaterMark** - _integer_ - The high water mark (in bytes) used for backpressure handling for this Xfer instance (default: 128KB)\n\n    * **streamHWM** - _integer_ - The high water mark (in bytes) used for the data streams for inbound messages (default: `highWaterMark` value from above)\n\n    * **skipWriteTick** - _boolean_ - This disables the use of process.nextTick() inside node core's Writable stream class after data is written to this xfer instance. This can help prevent exceeding the maximum call stack if you run into that issue. (default: false)\n\n * **send** (< _integer_ >type[, < _mixed_ >data]) - _boolean_ - Writes the message to the Readable stream portion of the Xfer instance. If provided, `data` can be either a Buffer or string. The return value indicates whether or not more sends should be performed.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/xfer/issues"},"_id":"xfer@0.2.1","dist":{"shasum":"7686789584ac9b16dddb198efbdeb4467bfa7843","tarball":"https://registry.npmjs.org/xfer/-/xfer-0.2.1.tgz","integrity":"sha512-oDibC103Qn3p+vBFKEY6gWzqCkCyyTcz9Kqw5p1OJhmwwZyW2dMBIWikr35G1LNCDcusS4z0uNb4Axn3Ub4FHg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEvHo8RHI5jIPvBbhPg09vZaT/h+yLkICjU2TV41qyprAiBjlCsTQVlV+RTmETRQlLD1wBJ7OKhFbCPBclq1sWClYg=="}]},"_from":"https://github.com/mscdex/xfer/tarball/v0.2.1","_resolved":"https://github.com/mscdex/xfer/tarball/v0.2.1","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]}},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}],"time":{"modified":"2022-06-29T05:07:13.226Z","created":"2011-08-05T05:54:10.661Z","0.0.1":"2011-08-05T05:54:11.275Z","0.0.2":"2012-01-08T10:59:03.650Z","0.0.3":"2012-03-20T05:56:41.583Z","0.1.0":"2012-03-20T22:27:05.959Z","0.1.1":"2012-08-01T22:39:30.613Z","0.1.2":"2012-08-02T05:46:56.128Z","0.2.0":"2013-10-26T04:09:45.391Z","0.2.1":"2013-11-10T03:35:29.778Z"},"author":{"name":"Brian White","email":"mscdex@mscdex.net"},"repository":{"type":"git","url":"http://github.com/mscdex/xfer.git"},"users":{"fgribreau":true}}