{ "name": "buffertools", "main": "buffertools", "version": "1.1.0", "keywords": [ "buffer", "buffers" ], "description": "Working with node.js buffers made easy.", "homepage": "https://github.com/bnoordhuis/node-buffertools", "author": { "name": "Ben Noordhuis", "email": "info@bnoordhuis.nl", "url": "http://bnoordhuis.nl/" }, "repository": { "type": "git", "url": "https://github.com/bnoordhuis/node-buffertools.git" }, "engines": { "node": ">=0.3.0" }, "scripts": { "install": "node-gyp rebuild" }, "gypfile": true, "contributors": [ { "name": "Ben Noordhuis", "email": "info@bnoordhuis.nl" }, { "name": "Nathan Rajlich", "email": "nathan@tootallnate.net" }, { "name": "Stefan Thomas", "email": "justmoon@members.fsf.org" } ], "readme": "# node-buffertools\n\nUtilities for manipulating buffers.\n\n## Installing the module\n\nEasy! With [npm](http://npmjs.org/):\n\n\tnpm install buffertools\n\nFrom source:\n\n\tnode-gyp configure\n\tnode-gyp build\n\nNow you can include the module in your project.\n\n\trequire('buffertools');\n\tnew Buffer(42).clear();\n\n## Methods\n\nNote that most methods that take a buffer as an argument, will also accept a string.\n\n### Buffer.clear()\n\nClear the buffer. This is equivalent to `Buffer.fill(0)`.\nReturns the buffer object so you can chain method calls.\n\n### Buffer.compare(buffer|string)\n\nLexicographically compare two buffers. Returns a number less than zero\nif a < b, zero if a == b or greater than zero if a > b.\n\nBuffers are considered equal when they are of the same length and contain\nthe same binary data.\n\nSmaller buffers are considered to be less than larger ones. Some buffers\nfind this hurtful.\n\n### Buffer.concat(a, b, c, ...)\n### buffertools.concat(a, b, c, ...)\n\nConcatenate two or more buffers/strings and return the result. Example:\n\n\t// identical to new Buffer('foobarbaz')\n\ta = new Buffer('foo');\n\tb = new Buffer('bar');\n\tc = a.concat(b, 'baz');\n\tconsole.log(a, b, c); // \"foo bar foobarbaz\"\n\n\t// static variant\n\tbuffertools.concat('foo', new Buffer('bar'), 'baz');\n\n### Buffer.equals(buffer|string)\n\nReturns true if this buffer equals the argument, false otherwise.\n\nBuffers are considered equal when they are of the same length and contain\nthe same binary data.\n\nCaveat emptor: If your buffers contain strings with different character encodings,\nthey will most likely *not* be equal.\n\n### Buffer.fill(integer|string|buffer)\n\nFill the buffer (repeatedly if necessary) with the argument.\nReturns the buffer object so you can chain method calls.\n\n### Buffer.fromHex()\n\nAssumes this buffer contains hexadecimal data (packed, no whitespace)\nand decodes it into binary data. Returns a new buffer with the decoded\ncontent. Throws an exception if non-hexadecimal data is encountered.\n\n### Buffer.indexOf(buffer|string, [start=0])\n\nSearch this buffer for the first occurrence of the argument, starting at\noffset `start`. Returns the zero-based index or -1 if there is no match.\n\n### Buffer.reverse()\n\nReverse the content of the buffer in place. Example:\n\n\tb = new Buffer('live');\n\tb.reverse();\n\tconsole.log(b); // \"evil\"\n\n### Buffer.toHex()\n\nReturns the contents of this buffer encoded as a hexadecimal string.\n\n## Classes\n\nSingular, actually. To wit:\n\n## WritableBufferStream\n\nThis is a regular node.js [writable stream](http://nodejs.org/docs/v0.3.4/api/streams.html#writable_Stream)\nthat accumulates the data it receives into a buffer.\n\nExample usage:\n\n\t// slurp stdin into a buffer\n\tprocess.stdin.resume();\n\tostream = new WritableBufferStream();\n\tutil.pump(process.stdin, ostream);\n\tconsole.log(ostream.getBuffer());\n\nThe stream never emits 'error' or 'drain' events.\n\n### WritableBufferStream.getBuffer()\n\nReturn the data accumulated so far as a buffer.\n\n## TODO\n\n* Logical operations on buffers (AND, OR, XOR).\n* Add lastIndexOf() functions.\n", "readmeFilename": "README.md", "_id": "buffertools@1.1.0", "dist": { "shasum": "97335a55f8347273aec0673bb981ab849e891416" }, "_from": "buffertools@>= 1.0.8" }