{"id":28552294,"url":"https://github.com/stream-utils/destroy-on-hwm","last_synced_at":"2025-07-06T08:30:56.011Z","repository":{"id":25195897,"uuid":"28619516","full_name":"stream-utils/destroy-on-hwm","owner":"stream-utils","description":"Destroy a writable stream if it hits the high water mark","archived":false,"fork":false,"pushed_at":"2016-01-26T20:52:48.000Z","size":5,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-27T21:07:00.444Z","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/stream-utils.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-30T05:57:31.000Z","updated_at":"2016-04-06T15:49:04.000Z","dependencies_parsed_at":"2022-07-24T04:46:07.113Z","dependency_job_id":null,"html_url":"https://github.com/stream-utils/destroy-on-hwm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stream-utils/destroy-on-hwm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stream-utils%2Fdestroy-on-hwm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stream-utils%2Fdestroy-on-hwm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stream-utils%2Fdestroy-on-hwm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stream-utils%2Fdestroy-on-hwm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stream-utils","download_url":"https://codeload.github.com/stream-utils/destroy-on-hwm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stream-utils%2Fdestroy-on-hwm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263870054,"owners_count":23522606,"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":"2025-06-10T04:08:37.028Z","updated_at":"2025-07-06T08:30:56.005Z","avatar_url":"https://github.com/stream-utils.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# destroy-on-hwm\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n[![Gittip][gittip-image]][gittip-url]\n\nDestroys a writable stream if a write ever hits the high water mark.\nThis is useful when piping a single stream to multiple clients -\nyou don't want one client slowing down the rest of the clients.\nWith how streams currently work, streams flow at the speed of the slowest destination stream.\n\n## Usage\n\n```js\nvar Stream = require('stream');\nvar destroyOnHWM = require('destroy-on-hwm');\n\nvar stream = new Stream.PassThrough();\n\n/**\n * With no callback, attempts to execute `stream.destroy()` on high water mark.\n * This stream does not have `.destroy()` though, so it's really a noop.\n */\n\ndestroyOnHWM(stream);\n\n/**\n * Instead, we'll just use a custom callback.\n */\n\ndestroyOnHWM(stream, function (stream) {\n  assert(stream === this); // the stream is passed as both `this` and the first argument\n  console.log('High water mark reached!');\n});\n```\n\n[gitter-image]: https://badges.gitter.im/stream-utils/destroy-on-hwm.png\n[gitter-url]: https://gitter.im/stream-utils/destroy-on-hwm\n[npm-image]: https://img.shields.io/npm/v/destroy-on-hwm.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/destroy-on-hwm\n[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy-on-hwm.svg?style=flat-square\n[github-url]: https://github.com/stream-utils/destroy-on-hwm/tags\n[travis-image]: https://img.shields.io/travis/stream-utils/destroy-on-hwm.svg?style=flat-square\n[travis-url]: https://travis-ci.org/stream-utils/destroy-on-hwm\n[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy-on-hwm.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/stream-utils/destroy-on-hwm\n[david-image]: http://img.shields.io/david/stream-utils/destroy-on-hwm.svg?style=flat-square\n[david-url]: https://david-dm.org/stream-utils/destroy-on-hwm\n[license-image]: http://img.shields.io/npm/l/destroy-on-hwm.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/destroy-on-hwm.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/destroy-on-hwm\n[gittip-image]: https://img.shields.io/gratipay/jonathanong.svg?style=flat-square\n[gittip-url]: https://gratipay.com/jonathanong/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstream-utils%2Fdestroy-on-hwm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstream-utils%2Fdestroy-on-hwm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstream-utils%2Fdestroy-on-hwm/lists"}