{"id":22394147,"url":"https://github.com/atlantis-software/streamize","last_synced_at":"2025-03-26T22:41:16.646Z","repository":{"id":57372183,"uuid":"129365039","full_name":"Atlantis-Software/streamize","owner":"Atlantis-Software","description":"stream helper for NodeJs","archived":false,"fork":false,"pushed_at":"2018-04-17T15:43:46.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T09:02:20.143Z","etag":null,"topics":["helper","stream"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atlantis-Software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-13T07:24:38.000Z","updated_at":"2018-04-17T15:43:47.000Z","dependencies_parsed_at":"2022-09-10T01:20:24.554Z","dependency_job_id":null,"html_url":"https://github.com/Atlantis-Software/streamize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fstreamize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fstreamize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fstreamize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fstreamize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atlantis-Software","download_url":"https://codeload.github.com/Atlantis-Software/streamize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245749796,"owners_count":20666084,"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":["helper","stream"],"created_at":"2024-12-05T05:09:11.272Z","updated_at":"2025-03-26T22:41:16.601Z","avatar_url":"https://github.com/Atlantis-Software.png","language":"JavaScript","readme":"# streamize\n\n[![npm version](https://badge.fury.io/js/streamize.svg)](https://www.npmjs.com/streamize)\n[![Build Status](https://travis-ci.org/Atlantis-Software/streamize.svg?branch=master)](https://travis-ci.org/Atlantis-Software/streamize)\n[![Coverage Status](https://coveralls.io/repos/github/Atlantis-Software/streamize/badge.svg?branch=master)](https://coveralls.io/github/Atlantis-Software/streamize?branch=master)\n[![NSP Status](https://nodesecurity.io/orgs/atlantis/projects/ed0ada30-0689-4121-b3b8-9d80f793d292/badge)](https://nodesecurity.io/orgs/atlantis/projects/ed0ada30-0689-4121-b3b8-9d80f793d292)\n[![Dependencies Status](https://david-dm.org/Atlantis-Software/streamize.svg)](https://david-dm.org/Atlantis-Software/streamize)\n\nstream helpers for NodeJs\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/).\n\nBefore installing, [download and install Node.js](https://nodejs.org/en/download/).\nNode.js 6 or higher is required.\n\nInstallation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```bash\n$ npm install streamize\n```\n\n## Documentation\n\n### Readable\n\nDescription: create a readable stream\n\n`streamize.Readable(read, [options])`\n* read is a function that take a callback function as argument.\n* options is an optional object argument passed to the node stream: [see node readable stream documentation](https://nodejs.org/api/stream.html#stream_new_stream_readable_options)\n\nreturn a readable stream\n\n#### sample\n```javascript\nvar streamize = require('streamize');\nvar myArray = ['1', '2', '3', '4', '5'];\n// create a readable stream from myArray\nvar readable = streamize.Readable(function(cb) {\n  cb(null, myArray.shift() || null);\n});\n```\n\nthe read function passed in argument is called each time a new chunk is required.\nthe callback takes 2 arguments:\n* error\n\nWhen error is defined and not null, the stream returned emit the error and chunk is ignored.\n* chunk\n\nWhen chunk is a Buffer, Uint8Array or string, the chunk of data will be added to the internal queue for users of the stream to consume.\nPassing chunk as null signals the end of the stream (EOF), after which no more data can be written.\n\nAs read function is called in the stream context, every internal function could be called from `this`.\n\n```javascript\nvar readable = streamize.Readable(function(cb) {\n  // push 'a' into the stream\n  this.push('a');\n  cb(null, myArray.shift() || null);\n});\n```\n\n### Writable\n\nDescription: create a writable stream\n\n`streamize.Writable(write, [options])`\n* write is a function that take the chunk to be written and a callback function as arguments.\n* options is an optional object argument passed to the node stream: [see node writable stream documentation](https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options)\n\n#### sample\n```javascript\nvar streamize = require('streamize');\nvar newArray = [];\n// create a writable stream that push chunk in newArray\nvar writable = streamize.Writable(function(chunk, cb) {\n  newArray.push(chunk);\n  cb();\n});\n```\n\nthe write function is called each time a chunk should be written.\nchunk \u003cBuffer\u003e | \u003cstring\u003e | \u003cany\u003e The chunk to be written. Will always be a buffer unless the decodeStrings option was set to false or the stream is operating in object mode.\ncallback \u003cFunction\u003e Call this function (optionally with an error argument) when processing is complete for the supplied chunk.\n\n### Duplex\n\nDescription: create a duplex stream\n\n`streamize.Duplex(read, write, [options])`\n* read is a function that take a callback function as argument.[see Readable read function](#readable)\n* write is a function that take the chunk to be written and a callback function as arguments.[see Writable write function](#writable)\n* options is an optional object argument passed to the node stream: [see node duplex stream documentation](https://nodejs.org/api/stream.html#stream_new_stream_duplex_options)\n\n#### sample\n```javascript\nvar streamize = require('streamize');\nvar myArray = ['1', '2', '3', '4', '5'];\nvar newArray = [];\n// create a duplex stream that read myArray and write in newArray\nvar duplex = streamize.Duplex(function(cb) {\n  cb(null, myArray.shift() || null);\n}, function(data, cb) {\n  newArray.push(chunk);\n  cb();\n});\n```\n\n### Transform\n\nDescription: create a transform stream\n\n`streamize.Transform(transform, [options])`\n* transform is a function that take the chunk to be transform and a callback function as arguments.\n* options is an optional object argument passed to the node stream: [see node transform stream documentation](https://nodejs.org/api/stream.html#stream_new_stream_transform_options)\n\n#### sample\n```javascript\nvar streamize = require('streamize');\n// create a transform stream that duplicate all chunks\nvar transform = streamize.Transform(function(chunk, cb) {\n  this.push(chunk);\n  cb(null, chunk);\n});\n```\n\nthe transform function is called each time a chunk should be transform.\nchunk \u003cBuffer\u003e | \u003cstring\u003e | \u003cany\u003e The chunk to be written. Will always be a buffer unless the decodeStrings option was set to false or the stream is operating in object mode.\ncallback \u003cFunction\u003e A callback function (optionally with an error argument and data) to be called after the supplied chunk has been processed.\n\nAs transform function is called in the stream context, every internal function could be called from `this`.\n\n### Object mode\n\n`streamize.obj.Readable(read, [options])`\n\n`streamize.obj.Writable(write, [options])`\n\n`streamize.obj.Duplex(read, write, [options])`\n\n`streamize.obj.Transform(transform, [options])`\n\ndo the same but return a stream in object mode.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlantis-software%2Fstreamize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatlantis-software%2Fstreamize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlantis-software%2Fstreamize/lists"}