{"_id":"buffer-reuse-pool","_rev":"4652856","name":"buffer-reuse-pool","description":"An easy way to reuse buffers without much API ceremony","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2026-04-10T20:50:00.000Z","created":"2018-03-04T10:01:02.995Z","1.0.0":"2018-03-04T10:01:02.995Z"},"users":{},"author":{"name":"Mathias Buus","url":"@mafintosh"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/buffer-reuse-pool.git"},"versions":{"1.0.0":{"name":"buffer-reuse-pool","version":"1.0.0","description":"An easy way to reuse buffers without much API ceremony","main":"index.js","dependencies":{},"devDependencies":{"standard":"^11.0.0","tape":"^4.9.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/buffer-reuse-pool.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/buffer-reuse-pool/issues"},"homepage":"https://github.com/mafintosh/buffer-reuse-pool","gitHead":"16a52c4d1170d02a6f205a2e32e2b2a83ac2d393","_id":"buffer-reuse-pool@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.6.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"c636dc13239a43e1b25633751bc0f7a9f00ef2f3","size":2569,"noattachment":false,"key":"/buffer-reuse-pool/-/buffer-reuse-pool-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/buffer-reuse-pool/download/buffer-reuse-pool-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/buffer-reuse-pool_1.0.0_1520157662934_0.514129107708948"},"_hasShrinkwrap":false,"publish_time":1520157662995,"_cnpm_publish_time":1520157662995,"_cnpmcore_publish_time":"2021-12-16T20:51:21.054Z"}},"readme":"# buffer-reuse-pool\n\nAn easy way to reuse buffers without much API ceremony\n\n```\nnpm install buffer-reuse-pool\n```\n\n[![build status](https://travis-ci.org/mafintosh/buffer-reuse-pool.svg?branch=master)](https://travis-ci.org/mafintosh/buffer-reuse-pool)\n\n## Usage\n\n``` js\nconst reuse = require('buffer-reuse-pool')\nconst pool = reuse.pool(65536) // make a pool of 64kb chunks\n\nconst buf = pool.alloc() // alloc a buffer\n\n// ... do stuff like passing it to fs.read\n// when done free it\n\nreuse.free(buf) // re-adds it to the pool it was allocated from\n```\n\nThe neat thing is that the `buf` variable is just a normal buffer and that the\nreuse function does not need to know about the pool, meaning that module authors\ncan support buffer reuse without any additional api complexities.\n\nAll you have to do is free a buffer when you are completely done using it\n\n## API\n\n#### `const pool = reuse.pool(size)`\n\nMake a new buffer reuse pool. `size` if the size of the buffers allocated.\n\n#### `pool.size`\n\nGet the buffer size of this pool.\n\n#### `const buffer = pool.alloc()`\n\nAllocate a new buffer of size `pool.size`.\nNote that the buffer is *not* guaranteed to be blank as it can have been used before.\n\n#### `const reusable = reuse.free(buffer)`\n\nFree a buffer. Returns `true` if this buffer was reuseable, `false` if not.\nIt is safe to pass a normal buffer allocated with `Buffer.alloc` or a one allocated with `pool.alloc`.\n\n#### `const slicedBuffer = reuse.slice(buffer, start, end)`\n\nSlice a buffer. If the `slicedBuffer` is freed the original `buffer` is reused.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mafintosh/buffer-reuse-pool","bugs":{"url":"https://github.com/mafintosh/buffer-reuse-pool/issues"},"license":"MIT"}