{"id":19621398,"url":"https://github.com/commenthol/streamss-through","last_synced_at":"2025-08-01T06:02:19.661Z","repository":{"id":24601146,"uuid":"28009688","full_name":"commenthol/streamss-through","owner":"commenthol","description":"A sync/async stream2 transformer","archived":false,"fork":false,"pushed_at":"2021-10-10T05:37:52.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T18:17:36.357Z","etag":null,"topics":["stream2","through","transform"],"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/commenthol.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":"2014-12-14T22:02:20.000Z","updated_at":"2021-10-10T05:37:55.000Z","dependencies_parsed_at":"2022-08-23T03:41:22.776Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/streamss-through","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fstreamss-through","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fstreamss-through/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fstreamss-through/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fstreamss-through/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/streamss-through/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240914946,"owners_count":19878069,"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":["stream2","through","transform"],"created_at":"2024-11-11T11:22:48.493Z","updated_at":"2025-02-26T18:46:06.806Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# streamss-through\n\n\u003e A sync/async stream2 transformer\n\n[![NPM version](https://badge.fury.io/js/streamss-through.svg)](https://www.npmjs.com/package/streamss-through/)\n[![Build Status](https://secure.travis-ci.org/commenthol/streamss-through.svg?branch=master)](https://travis-ci.org/commenthol/streamss-through)\n\nWorks with node v8.x and greater.\n\n`Through` can be used in synchronous mode with:\n\n```js\nconst { through } = require('streamss-through')\n\nprocess.stdin\n.pipe(through(\n  function transform (data){\n    // synchronous mode\n  },\n  function flush (){\n    // synchronous mode\n  }\n))\n```\n\nor in asynchronous mode:\n\n```js\nconst { through } = require('streamss-through')\n\nprocess.stdin\n.pipe(through(\n  function transform (data, enc, done){\n    // asynchronous mode\n    done() // explicit call of done required\n  },\n  function flush (done){\n    // asynchronous mode\n    done() // explicit call of done required\n  }\n))\n```\n\n## Through([options], transform, flush)\n\n**Parameters:**\n\n- `{Object} [options]` - Stream options\n- `{Boolean} options.objectMode` - Whether this stream should behave as a stream of objects. Default=false\n- `{Number} options.highWaterMark` - The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default=16kb\n- `{String} options.encoding` - Set encoding for string-decoder\n- `{Boolean} options.decodeStrings` - Do not decode strings if set to `false`. Default=true\n- `{Boolean} options.passError` - Pass error to next pipe. Default=true\n- `{Function} transform` - Function called on transform\n- `{Function} flush` - Function called on flush\n\n## throughObj([options], transform, flush)\n\n\u003e Shortcut for object mode\n\n**Parameters:**\n\n- `{Object} [options]` - Stream options\n- `{Function} transform` - Function called on transform\n- `{Function} flush` - Function called on flush\n\n\n### Example:\n\n```javascript\nconst { through } = require('streamss-through')\nlet cnt = 0\n\nrequire('fs').createReadStream(__filename, { encoding: 'utf8', highWaterMark: 30 })\n.pipe(through(\n  { decodeStrings: false },\n  function transform(str) {\n    cnt += 1\n    this.push(str.replace(/\\s/g, '‧') + '\\n')\n  },\n  function flush() {\n    console.log('\\ncounted num of chunks: ' + cnt)\n  }\n))\n.pipe(process.stdout)\n```\n\nTry it with:\n\n```bash\nnode examples/test.js\n```\n\nCheck out the [tests](./test/index.mocha.js) for more examples.\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your\ncode to be distributed under the MIT license. You are also implicitly\nverifying that all code is your original work or correctly attributed\nwith the source of its origin and licence.\n\n## License\n\nCopyright (c) 2014- Commenthol. (MIT License)\n\nSee [LICENSE][] for more info.\n\n[LICENSE]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fstreamss-through","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fstreamss-through","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fstreamss-through/lists"}