{"id":17095615,"url":"https://github.com/meyfa/measure-stream","last_synced_at":"2025-04-12T23:22:22.678Z","repository":{"id":14717492,"uuid":"76865934","full_name":"meyfa/measure-stream","owner":"meyfa","description":"Node streams that know their lengths.","archived":false,"fork":false,"pushed_at":"2025-04-11T23:29:05.000Z","size":606,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T00:28:38.052Z","etag":null,"topics":["chunk","length","measure","measure-stream","nodejs","size","stream"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/measure-stream","language":"TypeScript","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/meyfa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"meyfa"}},"created_at":"2016-12-19T13:47:41.000Z","updated_at":"2025-02-21T09:14:24.000Z","dependencies_parsed_at":"2023-02-19T03:00:35.805Z","dependency_job_id":"876c4fbe-564d-4da5-9e8e-f23c70292581","html_url":"https://github.com/meyfa/measure-stream","commit_stats":{"total_commits":90,"total_committers":5,"mean_commits":18.0,"dds":0.5,"last_synced_commit":"4e535442defba224ad7605fb6fa54021ab6d0784"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fmeasure-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fmeasure-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fmeasure-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fmeasure-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meyfa","download_url":"https://codeload.github.com/meyfa/measure-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248644213,"owners_count":21138570,"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":["chunk","length","measure","measure-stream","nodejs","size","stream"],"created_at":"2024-10-14T14:43:19.404Z","updated_at":"2025-04-12T23:22:22.654Z","avatar_url":"https://github.com/meyfa.png","language":"TypeScript","funding_links":["https://github.com/sponsors/meyfa"],"categories":[],"sub_categories":[],"readme":"# measure-stream\n\n[![CI](https://github.com/meyfa/measure-stream/actions/workflows/main.yml/badge.svg)](https://github.com/meyfa/measure-stream/actions/workflows/main.yml)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/8a458e83d62bf8a2c619/test_coverage)](https://codeclimate.com/github/meyfa/measure-stream/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/8a458e83d62bf8a2c619/maintainability)](https://codeclimate.com/github/meyfa/measure-stream/maintainability)\n\nA duplex (Transform) stream for Node.js that measures the data passing through it\nand emits that info accordingly. The following properties are available:\n\n* **chunks** - The number of processed chunks up until and including the one\n    that triggered the event.\n* **totalLength** - The sum of all chunk lengths. Will be 0 if the chunks are\n    something other than strings or buffers.\n\n\n## Install\n\n```\nnpm i measure-stream\n```\n\n\n## Usage\n\n```javascript\nconst MeasureStream = require('measure-stream')\n\nconst stream = new MeasureStream()\nstream.on('measure', function (info) {\n  console.log('chunk count:', info.chunks)\n  console.log('total length:', info.totalLength)\n})\n\n// You can then use 'stream' as you normally would, e.g.\n// ('source' is readable and 'target' is writable):\nsource.pipe(stream).pipe(target)\n```\n\nAs you can see, just one additional `.pipe()` call required to make it work!\n\nAdditionally, the last `measurement` is always available as a stream property.\nFor example, if all you need is the total size after a stream has been\nprocessed:\n\n```javascript\nstream.on('finish', function () {\n  const bytes = stream.measurements.totalLength\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeyfa%2Fmeasure-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeyfa%2Fmeasure-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeyfa%2Fmeasure-stream/lists"}