{ "name": "buffer-writer", "version": "1.0.0", "description": "a fast, efficient buffer writer", "main": "index.js", "scripts": { "test": "mocha" }, "repository": { "type": "git", "url": "git://github.com/brianc/node-buffer-writer.git" }, "keywords": [ "buffer", "writer", "builder" ], "author": { "name": "Brian M. Carlson" }, "license": "MIT", "devDependencies": { "mocha": "~1.8.1", "benchmark": "~1.0.0", "microtime": "~0.3.3", "bench": "~0.3.5", "okay": "0.0.2", "cloned": "0.0.1", "rmdir": "~1.0.0", "async": "~0.2.6" }, "readme": "# buffer-writer\n\n[![Build Status](https://secure.travis-ci.org/brianc/node-buffer-writer.png?branch=master)](http://travis-ci.org/brianc/node-buffer-writer)\n\nFast & efficient buffer writer used to keep memory usage low by internally recycling a single large buffer.\n\nUsed as the binary protocol writer in [node-postgres](https://github.com/brianc/node-postgres)\n\nSince postgres requires big endian encoding, this only writes big endian numbers for now, but can & probably will easily be extended to write little endian as well.\n\nI'll admit this has a few postgres specific things I might need to take out in the future, such as `addHeader`\n\n## api\n\n`var writer = new (require('buffer-writer')());`\n\n### writer.addInt32(num)\n\nWrites a 4-byte big endian binary encoded number to the end of the buffer.\n\n### writer.addInt16(num)\n\nWrites a 2-byte big endian binary encoded number to the end of the buffer.\n\n### writer.addCString(string)\n\nWrites a string to the buffer `utf8` encoded and adds a null character (`\\0`) at the end.\n\n### var buffer = writer.addHeader(char)\n\nWrites the 5 byte PostgreSQL required header to the beginning of the buffer. (1 byte for character, 1 BE Int32 for length of the buffer)\n\n### var buffer = writer.join()\n\nCollects all data in the writer and joins it into a single, new buffer.\n\n### var buffer = writer.flush(char)\n\nWrites the 5 byte postgres required message header, collects all data in the writer and joins it into a single, new buffer, and then resets the writer.\n\n## thoughts\n\nThis is kind of node-postgres specific. If you're interested in using this for a more general purpose thing, lemme know.\nI would love to work with you on getting this more reusable for your needs.\n\n## license\n\nMIT\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/brianc/node-buffer-writer/issues" }, "_id": "buffer-writer@1.0.0", "dist": { "shasum": "6c29c3b2dea0c9e455a1f261a199a48a04f88b08", "tarball": "http://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.0.tgz" }, "_from": "buffer-writer@1.0.0", "_npmVersion": "1.3.11", "_npmUser": { "name": "brianc", "email": "brian.m.carlson@gmail.com" }, "maintainers": [ { "name": "brianc", "email": "brian.m.carlson@gmail.com" } ], "directories": {}, "_shasum": "6c29c3b2dea0c9e455a1f261a199a48a04f88b08", "_resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.0.tgz", "homepage": "https://github.com/brianc/node-buffer-writer" }