{"id":20767007,"url":"https://github.com/binded/common-streams","last_synced_at":"2025-03-11T18:51:24.013Z","repository":{"id":57157568,"uuid":"67156782","full_name":"binded/common-streams","owner":"binded","description":"common-streams","archived":false,"fork":false,"pushed_at":"2016-10-28T04:58:51.000Z","size":2400,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-01T23:37:16.322Z","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/binded.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":"2016-09-01T18:37:55.000Z","updated_at":"2016-09-01T18:43:08.000Z","dependencies_parsed_at":"2022-09-07T20:33:18.188Z","dependency_job_id":null,"html_url":"https://github.com/binded/common-streams","commit_stats":null,"previous_names":["blockai/common-streams"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fcommon-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fcommon-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fcommon-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fcommon-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binded","download_url":"https://codeload.github.com/binded/common-streams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243094590,"owners_count":20235531,"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-11-17T11:27:13.120Z","updated_at":"2025-03-11T18:51:23.989Z","avatar_url":"https://github.com/binded.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# common-streams\n\n[![Build Status](https://travis-ci.org/blockai/common-streams.svg?branch=master)](https://travis-ci.org/blockai/common-streams)\n\nA collection of useful streams.\n\n## Install\n\n```bash\nnpm install --save common-streams\n```\n\nRequires Node v6+\n\n## Usage\n\nSee [./test](./test) directory for more usage examples.\n\nExample:\n\n```javascript\nimport { HashStream, SizeStream } from 'common-streams'\nimport concat from 'concat-stream'\n\nconst rs = getReadStream() // e.g. fs.createReadStream(...)\nconst ws = getWriteStream() // e.g. fs.createWriteStream(...)\n\nconst sha1Stream = new HashStream('sha1')\nconst sizeStream = new SizeStream()\n\nrs.pipe(sha1Stream).pipe(concat(([{ digest }]) =\u003e {\n  console.log(digest, '=', '4129def2ea7cb7945ddfbb785969898fca2e34c3')\n}))\nrs.pipe(sizeStream).pipe(concat(([{ size }]) =\u003e {\n  console.log(size, '=', 2447774)\n}))\nrs.pipe(ws)\n```\n\n### HashStream\n\nTransform stream that operates in object mode and returns a single `{ digest: 'hash digest' }` object.\n\n`new HashStream(algorithm, [, opts])`\n\n**algorithm**: any algorithm supported by [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm)\n\n**opts.encoding**: any encoding supported by [hash.digest](https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding). Defaults to `hex`.\n\n### SizeStream\n\nTransform stream that operates in object mode and returns a single `{\nsize: 1000 }` object where the size is an integer representing the total\nsize in bytes of the stream.\n\n`new SizeStream()`\n\nIf passed a callback `new SizeStream(cb)` it will just act as a\nPassThrough stream and call the callback when it's done.\n\n### RandomStream\n\n`new RandomStream(max)`\n\nReadable stream that emits `max` random bytes before ending.\n\n### DiscardStream\n\n`new DiscardStream(start)`\n\nSwallows all bytes until `start` is reached.\n\n### MeterStream\n\n`new MeterStream(max)`\n\nSee [meterstream](https://github.com/blockai/meterstream)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fcommon-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinded%2Fcommon-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fcommon-streams/lists"}