{"_id":"buffer-builder","_rev":"3348935","name":"buffer-builder","description":"Build a buffer without knowing its size beforehand","dist-tags":{"latest":"0.2.0"},"maintainers":[{"name":"peterreid","email":""}],"time":{"modified":"2024-08-12T07:53:36.000Z","created":"2012-02-27T00:43:45.507Z","0.2.0":"2015-01-10T17:36:57.991Z","0.1.0":"2012-02-27T00:43:45.507Z"},"users":{},"author":{"name":"Peter Reid","email":"peter.d.reid@gmail.com"},"repository":{"type":"git","url":"http://github.com/PeterReid/node-buffer-builder.git"},"versions":{"0.2.0":{"name":"buffer-builder","version":"0.2.0","description":"Build a buffer without knowing its size beforehand","main":"buffer-builder","repository":{"type":"git","url":"http://github.com/PeterReid/node-buffer-builder.git"},"keywords":["buffer-builder","buffer"],"author":{"name":"Peter Reid","email":"peter.d.reid@gmail.com"},"license":"MIT/X11","engine":{"node":">=0.6.0"},"gitHead":"054d9605da754cc457baad8a6cfe31bedebe7a0a","bugs":{"url":"https://github.com/PeterReid/node-buffer-builder/issues"},"homepage":"https://github.com/PeterReid/node-buffer-builder","_id":"buffer-builder@0.2.0","scripts":{},"_shasum":"3322cd307d8296dab1f604618593b261a3fade8f","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"peterreid","email":"peter.d.reid@gmail.com"},"maintainers":[{"name":"peterreid","email":""}],"dist":{"shasum":"3322cd307d8296dab1f604618593b261a3fade8f","size":5686,"noattachment":false,"key":"/buffer-builder/-/buffer-builder-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/buffer-builder/download/buffer-builder-0.2.0.tgz"},"directories":{},"publish_time":1420911417991,"_hasShrinkwrap":false,"_cnpm_publish_time":1420911417991,"_cnpmcore_publish_time":"2021-12-17T11:35:56.985Z"},"0.1.0":{"name":"buffer-builder","version":"0.1.0","description":"Build a buffer without knowing its size beforehand","main":"buffer-builder","repository":{"type":"git","url":"git://github.com/PeterReid/buffer-builder.git"},"keywords":["buffer-builder","buffer"],"author":{"name":"Peter Reid","email":"peter.d.reid@gmail.com"},"license":"MIT/X11","engine":{"node":">=0.6.0"},"_npmUser":{"name":"peterreid","email":"peter.d.reid@gmail.com"},"_id":"buffer-builder@0.1.0","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.0-beta-4","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"a8d24d91d5086abe07c239274a7d27832ee1cc12","size":5601,"noattachment":false,"key":"/buffer-builder/-/buffer-builder-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/buffer-builder/download/buffer-builder-0.1.0.tgz"},"maintainers":[{"name":"peterreid","email":""}],"directories":{},"publish_time":1330303425507,"_hasShrinkwrap":false,"_cnpm_publish_time":1330303425507,"_cnpmcore_publish_time":"2021-12-17T11:35:57.226Z"}},"readme":"# buffer-builder.js\r\n\r\nBufferBuilder accumulates pieces of data into a buffer, appending each onto the end. The data can be Buffers, strings, a repetition of a byte, or any of the types such as UInt32LE or FloatBE that can be written into Buffers.\r\n\r\nIf you are thinking about using this, you should probably have considered streaming your data instead of putting it into a buffer.\r\n\r\n## Usage\r\n\r\n``` js\r\nvar BufferBuilder = require('buffer-builder');\r\nvar helloWorld = new BufferBuilder();\r\n\r\n// Append a string, utf8 encoded by default.\r\nhelloWorld.appendString('hello');\r\n\r\n// Append any type that Buffer has read and write functions for.\r\nhelloWorld.appendUInt16LE(0x7720);\r\n\r\n// Append a buffer\r\nhelloWorld.appendBuffer(new Buffer([111, 114, 108, 100]));\r\n\r\n// Appended a repetition of a byte\r\nhelloWorld.appendFill(33, 3);\r\n\r\n// Convert to an ordinary buffer\r\nvar buffer = helloWorld.get();\r\n\r\nbuffer.toString(); // hello world!!!\r\n```\r\n\r\n## API\r\n\r\n### new BufferBuilder([initialCapacity])\r\nAllocate an empty BufferBuilder. If you know approximately what size the Buffer will end up being and are trying to squeeze out more performance, you can set the initial size of the backing buffer.\r\n\r\n### appendBuffer(source)\r\nAppend a buffer. Use [slice](http://nodejs.org/docs/latest/api/buffers.html#buffer.slice) if you want to append just part of one.\r\n\r\n### appendString(string, [encoding])\r\nAppend a string, encoded by utf8 by default. No trailing 0 is appended.\r\n\r\n### appendStringZero(string, [encoding])\r\nAppend a null-terminated string, encoded by utf8 by default.\r\n\r\n### appendUInt8(value)\r\nAppend 8-bit unsigned integer.\r\n\r\n### appendUInt16LE(value)\r\nAppend 16-bit unsigned integer, little endian. 1 is encoded as 01 00.\r\n\r\n### appendUInt16BE(value)\r\nAppend 16-bit unsigned integer, big endian. 1 is encoded as 00 01.\r\n\r\n### appendUInt32LE(value)\r\nAppend 32-bit unsigned integer, little endian. 1 is encoded as 01 00 00 00.\r\n\r\n### appendUInt32BE(value)\r\nAppend 32-bit unsigned integer, big endian. 1 is encoded as 00 00 00 01.\r\n\r\n### appendInt8(value)\r\nAppend 8-bit signed integer.\r\n\r\n### appendInt16LE(value)\r\nAppend 16-bit signed integer, little endian. 1 is encoded as 01 00.\r\n\r\n### appendInt16BE(value)\r\nAppend 16-bit signed integer, big endian. 1 is encoded as 00 01.\r\n\r\n### appendInt32LE(value)\r\nAppend 32-bit signed integer, little endian. 1 is encoded as 01 00 00 00.\r\n\r\n### appendInt32BE(value)\r\nAppend 32-bit signed integer, big endian. 1 is encoded as 00 00 00 01.\r\n\r\n### appendFloatLE(value)\r\nLittle-endian float. Occupies 4 bytes.\r\n\r\n### appendFloatBE(value)\r\nBig-endian float. Occupies 4 bytes.\r\n\r\n### appendDoubleLE(value)\r\nLittle-endian double. Occupies 8 bytes.\r\n\r\n### appendDoubleBE(value)\r\nBig-endian double. Occupies 8 bytes.\r\n\r\n### appendFill(value, count)\r\nAppend _count_ repetitions of _value_ (a byte).\r\n\r\n### get()\r\nConvert to a buffer. This is a deep copy; modifications to the returned buffer will not affect the BufferBuilder.\r\n\r\n### copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd])\r\nCopy bytes from the BufferBuilder into _targetBuffer_. _targetStart_ and _sourceStart_ default to 0. _sourceEnd_ defaults to the BufferBuilder's length.\r\n\r\n### length\r\nNumber of bytes appended so far.\r\n","_attachments":{},"homepage":"https://github.com/PeterReid/node-buffer-builder","bugs":{"url":"https://github.com/PeterReid/node-buffer-builder/issues"},"license":"MIT/X11"}