{"id":17859329,"url":"https://github.com/dex4er/js-promise-duplex","last_synced_at":"2025-03-20T19:30:51.264Z","repository":{"id":18745067,"uuid":"84688819","full_name":"dex4er/js-promise-duplex","owner":"dex4er","description":"Return promise for duplex stream","archived":false,"fork":false,"pushed_at":"2025-03-10T23:02:04.000Z","size":120,"stargazers_count":4,"open_issues_count":9,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T00:19:01.105Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/promise-duplex","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/dex4er.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}},"created_at":"2017-03-12T00:18:45.000Z","updated_at":"2024-06-21T13:04:01.000Z","dependencies_parsed_at":"2023-10-12T22:11:03.828Z","dependency_job_id":"c891bc54-5a33-4cf0-ad28-b3f8ffaf0146","html_url":"https://github.com/dex4er/js-promise-duplex","commit_stats":{"total_commits":108,"total_committers":2,"mean_commits":54.0,"dds":0.2407407407407407,"last_synced_commit":"b704fe2e12aa40af329138fcbafbb21000169610"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fjs-promise-duplex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fjs-promise-duplex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fjs-promise-duplex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fjs-promise-duplex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dex4er","download_url":"https://codeload.github.com/dex4er/js-promise-duplex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244079844,"owners_count":20394798,"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":["hacktoberfest"],"created_at":"2024-10-28T06:42:24.982Z","updated_at":"2025-03-20T19:30:50.812Z","avatar_url":"https://github.com/dex4er.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# promise-duplex\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n\n[![GitHub](https://img.shields.io/github/v/release/dex4er/js-promise-duplex?display_name=tag\u0026sort=semver)](https://github.com/dex4er/js-promise-duplex)\n[![CI](https://github.com/dex4er/js-promise-duplex/actions/workflows/ci.yaml/badge.svg)](https://github.com/dex4er/js-promise-duplex/actions/workflows/ci.yaml)\n[![Trunk Check](https://github.com/dex4er/js-promise-duplex/actions/workflows/trunk.yaml/badge.svg)](https://github.com/dex4er/js-promise-duplex/actions/workflows/trunk.yaml)\n[![Coverage Status](https://coveralls.io/repos/github/dex4er/js-promise-duplex/badge.svg)](https://coveralls.io/github/dex4er/js-promise-duplex)\n[![npm](https://img.shields.io/npm/v/promise-duplex.svg)](https://www.npmjs.com/package/promise-duplex)\n\n\u003c!-- markdownlint-enable MD013 --\u003e\n\nThis module allows to convert\n[`Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex) stream\ninto its promisified version, which returns\n[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\nobject fulfilled when stream's events occurred.\n\nThe module combines\n[`promise-readable`](https://www.npmjs.com/package/promise-readable) and\n[`promise-`](https://www.npmjs.com/package/promise-) in one.\n\n## Requirements\n\nThis module requires Node \u003e= 16.\n\n## Installation\n\n```shell\nnpm install promise-duplex\n```\n\n## Usage\n\n```js\nimport PromiseDuplex from \"promise-duplex\"\n```\n\n### constructor\n\n```js\nconst promiseDuplex = new PromiseDuplex(stream)\n```\n\n`PromiseDuplex` object requires `Duplex` object to work.\n\n_Example:_\n\n```js\nimport net from \"node:net\"\nimport PromiseDuplex from \"promise-duplex\"\n\nconst stream = new net.Socket()\n\nconst promiseDuplex = new PromiseDuplex(stream)\n```\n\n### stream\n\n```js\nconst stream = promiseDuplex.stream\n```\n\nOriginal stream object.\n\n_Example:_\n\n```js\nconsole.log(promiseDuplex.stream.localAddress)\n```\n\n### read\n\n```js\nconst chunk = await promiseDuplex.read(chunkSize)\n```\n\nCheck\n[`PromiseReadable.read`](https://www.npmjs.com/package/promise-readable#read)\nfor details.\n\n### readAll\n\n```js\nconst content = await promiseDuplex.readAll()\n```\n\nCheck\n[`PromiseReadable.readAll`](https://www.npmjs.com/package/promise-readable#readall)\nfor details.\n\n### iterate\n\n```js\nfor await (const chunk of promiseDuplex.iterate(chunkSize)) {\n}\n```\n\nCheck\n[`PromiseReadable.iterate`](https://www.npmjs.com/package/promise-readable#iterate)\nfor details.\n\n### Symbol.asyncIterator\n\n```js\nfor await (const chunk of promiseDuplex.iterate(chunkSize)) {\n}\n```\n\nCheck\n[`PromiseReadable[Symbol.asyncIterator]`](https://www.npmjs.com/package/promise-readable#symbolasynciterator)\nfor details.\n\n### setEncoding\n\n```js\npromiseDuplex = await promiseDuplex.setEncoding(encoding)\n```\n\nCheck\n[`PromiseReadable.setEncoding`](https://www.npmjs.com/package/promise-readable#setencoding)\nfor details.\n\n### write\n\n```js\nawait promiseDuplex.write(chunk)\n```\n\nCheck\n[`PromiseWritable.write`](https://www.npmjs.com/package/promise-#write)\nfor details.\n\n### writeAll\n\n```js\nawait promiseDuplex.writeAll(content, chunkSize)\n```\n\nCheck\n[`PromiseWritable.writeAll`](https://www.npmjs.com/package/promise-#writeall)\nfor details.\n\n### end\n\n```js\nawait promiseDuplex.end()\n```\n\nCheck\n[`PromiseWritable.once`](https://www.npmjs.com/package/promise-#end)\nfor details.\n\n### once\n\n```js\nconst result = await promiseDuplex.once(event)\n```\n\nCheck\n[`PromiseReadable.once`](https://www.npmjs.com/package/promise-readable#once)\nand\n[`PromiseWritable.once`](https://www.npmjs.com/package/promise-#once)\nfor details.\n\n### destroy\n\n```js\npromiseDuplex = promiseDuplex.destroy()\n```\n\nThis method calls `destroy` method on stream and cleans up all own handlers.\n\nThe method returns this object.\n\n## See also\n\n[`PromiseReadable`](https://www.npmjs.com/package/promise-readable),\n[`PromiseWritable`](https://www.npmjs.com/package/promise-),\n[`PromiseSocket`](https://www.npmjs.com/package/promise-socket),\n[`PromisePiping`](https://www.npmjs.com/package/promise-piping).\n\n## License\n\nCopyright (c) 2017-2024 Piotr Roszatycki \u003cpiotr.roszatycki@gmail.com\u003e\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdex4er%2Fjs-promise-duplex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdex4er%2Fjs-promise-duplex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdex4er%2Fjs-promise-duplex/lists"}