GT2/GT2-Android/node_modules/smart-buffer/package.json

107 lines
13 KiB
JSON
Raw Normal View History

{
"_args": [
[
{
"raw": "smart-buffer@^1.0.13",
"scope": null,
"escapedName": "smart-buffer",
"name": "smart-buffer",
"rawSpec": "^1.0.13",
"spec": ">=1.0.13 <2.0.0",
"type": "range"
},
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/socks"
]
],
"_from": "smart-buffer@>=1.0.13 <2.0.0",
"_id": "smart-buffer@1.1.15",
"_inCache": true,
"_location": "/smart-buffer",
"_nodeVersion": "6.1.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/smart-buffer-1.1.15.tgz_1485802535898_0.37321774289011955"
},
"_npmUser": {
"name": "joshglazebrook",
"email": "npm@joshglazebrook.com"
},
"_npmVersion": "3.8.6",
"_phantomChildren": {},
"_requested": {
"raw": "smart-buffer@^1.0.13",
"scope": null,
"escapedName": "smart-buffer",
"name": "smart-buffer",
"rawSpec": "^1.0.13",
"spec": ">=1.0.13 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/socks"
],
"_resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz",
"_shasum": "7f114b5b65fab3e2a35aa775bb12f0d1c649bf16",
"_shrinkwrap": null,
"_spec": "smart-buffer@^1.0.13",
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/socks",
"author": {
"name": "Josh Glazebrook"
},
"bugs": {
"url": "https://github.com/JoshGlazebrook/smart-buffer/issues"
},
"dependencies": {},
"description": "A smarter Buffer that keeps track of its own read and write positions while growing endlessly.",
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.11.15",
"istanbul": "^0.4.3",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.2.0"
},
"directories": {},
"dist": {
"shasum": "7f114b5b65fab3e2a35aa775bb12f0d1c649bf16",
"tarball": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz"
},
"engines": {
"node": ">= 0.10.15",
"npm": ">= 1.3.5"
},
"gitHead": "071f618b339a341c2617ac41ea2a77132fd307e8",
"homepage": "https://github.com/JoshGlazebrook/smart-buffer/",
"keywords": [
"buffer",
"smart",
"serialize",
"packet",
"network",
"cursor",
"simple"
],
"license": "MIT",
"main": "lib/smart-buffer.js",
"maintainers": [
{
"name": "joshglazebrook",
"email": "josh@joshglazebrook.com"
}
],
"name": "smart-buffer",
"optionalDependencies": {},
"readme": "smart-buffer [![Build Status](https://travis-ci.org/JoshGlazebrook/smart-buffer.svg?branch=master)](https://travis-ci.org/JoshGlazebrook/smart-buffer) [![Coverage Status](https://coveralls.io/repos/github/JoshGlazebrook/smart-buffer/badge.svg?branch=master)](https://coveralls.io/github/JoshGlazebrook/smart-buffer?branch=master)\n=============\n\nsmart-buffer is a light Buffer wrapper that takes away the need to keep track of what position to read and write data to and from the underlying Buffer. It also adds null terminating string operations and **grows** as you add more data.\n\n\n### What it's useful for:\n\nI created smart-buffer because I wanted to simplify the process of using Buffer for building and reading network packets to send over a socket. Rather than having to keep track of which position I need to write a UInt16 to after adding a string of variable length, I simply don't have to.\n\nKey Features:\n* Proxies all of the Buffer write and read functions.\n* Keeps track of read and write positions for you.\n* Grows the internal Buffer as you add data to it. \n* Useful string operations. (Null terminating strings)\n* Allows for inserting values at specific points in the internal Buffer.\n\n#### Note:\nsmart-buffer can be used for writing to an underlying buffer as well as reading from it. It however does not function correctly if you're mixing both read and write operations with each other.\n\n## Installing:\n\n`npm install smart-buffer`\n\n## Using smart-buffer\n\n### Example\n\nSay you were building a packet that had to conform to the following protocol:\n\n`[PacketType:2][PacketLength:2][Data:XX]`\n\nTo build this packet using the vanilla Buffer class, you would have to count up the length of the data payload beforehand. You would also need to keep track of the current \"cursor\" position in your Buffer so you write everything in the right places. With smart-buffer you don't have to do either of those things.\n\n```javascript\nfunction createLoginPacket(username, password, age, country) {\n var packet = new SmartBuffer();\n packet.writeUInt16LE(0x0060); // Login Packet Type/ID\n packet.writeStringNT(username);\n packet.writeStringNT(password);\n packet.writeUInt8(age);\n packet.writeStringNT(country);\n packet.writeUInt16LE(packet.length - 2, 2);\n \n return packet.toBuffer();\n}\n```\nWith the above function, you now can do this:\n```javascript\nvar login = createLoginPacket(\"Josh\", \"secret123\", 22, \"United States\");\n\n// <Buffer 60 00 1e 00 4a 6f 73 68 00 73 65 63 72 65 74 31 32 33 00 16 55 6e 69 74 65 64 20 53 74 61 74 65 73 00>\n```\nNotice that the `[PacketLength:2]` part of the packet was inserted after we had added everything else, and as shown in the Buffer dump above, is in the correct location along with everything else.\n\nReading back the packet we created above is just as easy:\n```javascript\n\nvar reader = new SmartBuffer(login);\n\nvar logininfo = {\n packetType: reader.readUInt16LE(),\n packetLength: reader.readUInt16LE(),\n username: reader.readStringNT(),\n password: reader.readStringNT(),\n age: reader.readUInt8(),\n country: reader.readStringNT()\n};\n\n/*\n{ \n packetType: 96, (0x0060)\n packetLength: 30,\n username: 'Josh',\n password: 'secret123',\n age: 22,\n country: 'United States' \n};\n*/\n```\n\n# Api Reference:\n\n### Constructing a smart-buffer\n\nsmart-buffer has a few different constructor signatures you can use. By default, utf8 encoding is used, and the internal Buffer length will be 4096. When reading from a Buffer, smart-buffer does NOT make a copy of the Buffer. It reads from the Buffer it was given.\n\n```javascript\nvar SmartBuffer = require('smart-buffer');\n\n// Reading from an existing Buffer:\nvar reader = new SmartBuffer(buffer);\nvar reader = new SmartBuffer(buffer, 'ascii');\n\n// Writing to a new Buffer:\nvar writer = new SmartBuffer(); // Defaults to utf8, 4096 length internal Buffer.\nvar writer = new SmartBuffer(1024); // Defaults to utf8, 1024 lengt
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/JoshGlazebrook/smart-buffer.git"
},
"scripts": {
"coverage": "istanbul cover node_modules/mocha/bin/_mocha recursive test",
"fullcoverage": "istanbul -include-all-sources cover node_modules/mocha/bin/_mocha recursive test",
"test": "mocha test/smart-buffer.test.js"
},
"typings": "typings/index",
"version": "1.1.15"
}