{"id":17238039,"url":"https://github.com/jsantell/streambuffers","last_synced_at":"2025-07-22T01:31:30.354Z","repository":{"id":28846663,"uuid":"32370533","full_name":"jsantell/streambuffers","owner":"jsantell","description":"Buffer-based readable and writable streams","archived":false,"fork":false,"pushed_at":"2018-11-09T21:48:50.000Z","size":67,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-17T03:28:01.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsantell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-17T03:57:35.000Z","updated_at":"2023-01-14T21:03:55.000Z","dependencies_parsed_at":"2022-09-05T08:50:21.127Z","dependency_job_id":null,"html_url":"https://github.com/jsantell/streambuffers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsantell/streambuffers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fstreambuffers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fstreambuffers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fstreambuffers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fstreambuffers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsantell","download_url":"https://codeload.github.com/jsantell/streambuffers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fstreambuffers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265595961,"owners_count":23794811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T05:44:28.623Z","updated_at":"2025-07-22T01:31:30.317Z","avatar_url":"https://github.com/jsantell.png","language":"JavaScript","readme":"# streambuffers\n\n[![Build Status](http://img.shields.io/travis/jsantell/streambuffers.svg?style=flat-square)](https://travis-ci.org/jsantell/streambuffers)\n[![Build Status](http://img.shields.io/npm/v/streambuffers.svg?style=flat-square)](https://www.npmjs.org/package/streambuffers)\n\nBuffer-based writable and readable streams, using streams2-based inheritance.\n\n## Install\n\n```\nnpm install streambuffers\n```\n\n## Usage\n\n\n```javascript\nvar stream = require(\"bufferstreams\");\n\n// Yes, you could just use fs.createReadStream here\nvar buffer = fs.readFileSync(__dirname + \"/file.mp3\")\n\n// Turn a buffer into a readable stream right away\nstream.Readable(buffer, { chunkSize: Math.pow(2, 16), frequency: 1 })\n  .on(\"data\", function (d) { console.log(d); })\n  .on(\"end\", function () { console.log(\"done!\"); });\n\n// Or push chunks afterwards\nvar readable = stream.Readable();\n\nreadable.put(new Buffer(100));\nreadable.put(new Buffer(100));\n// Close by calling `put` with `null`\nreadable.put(null);\n\nreadable.on(\"data\", function (d) { console.log(d); });\n\n// Buffer write streams for piping data into a buffer\n\nvar writable = stream.Writable();\nfs.createReadStream(__dirname + \"/file.mp3\")\n  .pipe(writable)\n  .on(\"end\", function () {\n    // Fetch buffer with `toBuffer`\n    var buffer = writable.toBuffer();\n  });\n```\n\n## API\n\n### `stream.Writable(options)`\n\nConstructor for Buffer Writable stream; takes options for [WritableStream](https://nodejs.org/api/stream.html#stream_class_stream_writable).\n\n#### `writable.toBuffer()`\n\nReturns the stored buffer after the writable stream is completed.\n\n### `stream.Readable(buffer, options)`\n\nTakes an optional buffer or optional [ReadableStream](https://nodejs.org/api/stream.html#stream_class_stream_readable) options. If supplied `buffer`, no further data can be added, but the stream starts being readable immediately, without having to specify `stream.put(null)` to explicitly close.\n\nTakes additional options of `chunkSize` to specify how many bytes should each push contain, as well as a `frequency` to specify how fast the pushes should occur, in milliseconds.\n\n#### `readable.put(buffer)`\n\nPushes a buffer to the Readable stream for it to push downstream. Cannot use if supplied a buffer in the constructor. Must call `readable.put(null)` to signify an end of the stream.\n\n## Testing\n\n```\nnpm test\n```\n\n## License\n\nMIT License, Copyright (c) 2015 Jordan Santell\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsantell%2Fstreambuffers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsantell%2Fstreambuffers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsantell%2Fstreambuffers/lists"}