{"id":20662580,"url":"https://github.com/system233/node-binary-streams","last_synced_at":"2025-07-03T14:05:25.596Z","repository":{"id":163528061,"uuid":"638540929","full_name":"System233/node-binary-streams","owner":"System233","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-15T06:53:52.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T10:07:57.506Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/System233.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-09T15:12:25.000Z","updated_at":"2023-05-09T15:12:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe9195a2-ab98-4b91-b295-b35dcfe6c9f3","html_url":"https://github.com/System233/node-binary-streams","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/System233/node-binary-streams","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/System233%2Fnode-binary-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/System233%2Fnode-binary-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/System233%2Fnode-binary-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/System233%2Fnode-binary-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/System233","download_url":"https://codeload.github.com/System233/node-binary-streams/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/System233%2Fnode-binary-streams/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263339888,"owners_count":23451513,"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-16T19:14:40.841Z","updated_at":"2025-07-03T14:05:25.494Z","avatar_url":"https://github.com/System233.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary Streams\n\n[![npm][npm-image]][npm-url]\n\n[npm-image]: https://img.shields.io/npm/v/binary-streams.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/binary-streams\n\nA `BufferLike` Binary Stream Wrapper for Node `Readable`/`Writable`/`Duplex` Stream.\n\n## Installation\n\n```sh\nnpm install binary-streams\n```\n\n## Usages\nFor `Readable` stream\n```ts\n    import { BinaryReadStream } from \"binary-streams\";\n    import { Readable } from \"node:stream\";\n\n    const buffer = Buffer.from([\n        0x78, 0x56, 0x34, 0x12, \n        0xff, 0xff\n    ]);\n    const rstream=new Readable({\n        read(){\n            stream.push(buffer)\n            stream.push(null)\n        }\n    });\n    const stream = BinaryReadStream.from(rstream);\n    console.log('readInt32LE','0x'+(await stream.readInt32LE()).toString(16));\n    console.log('readInt8',await stream.readInt8());\n    console.log('readUint8',await stream.readUint8());\n\n// OUTPUT:\n// readInt32LE 0x12345678\n// readInt8 -1\n// readUint8 255\n```\n\nFor `Writable` stream\n```ts\n    import { BinaryWriteStream } from \"binary-streams\";\n    import { Writable } from \"node:stream\";\n\n    const wstream=new Writable();\n    wstream._write=chunk=\u003econsole.log('write',chunk);\n\n    const stream=BinaryWriteStream.from(wstream);\n    stream.writeInt32(0x12345678)\n\n// OPTPUT:\n// write \u003cBuffer 78 56 34 12\u003e\n```\n\nFor `Duplex` stream\n```ts\n    import { BinaryDuplexStream } from \"binary-streams\"\n    import net from 'node:net'\n\n    const server = net.createServer((socket) =\u003esocket.pipe(socket));\n    server.listen()\n    const {address:host,port}=server.address();\n    const stream=BinaryDuplexStream.from(net.connect({host,port}));\n\n    stream.writeInt32LE(0x12345678);\n    const result=await stream.readInt32LE();\n\n    console.log('result','0x'+result.toString(16));\n    stream.end();\n    server.close();\n\n// OUTPUT:\n// result 0x12345678\n```\n\n## License\n\n[MIT License](LICENSE) Copyright (c) 2023 System233\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystem233%2Fnode-binary-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystem233%2Fnode-binary-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystem233%2Fnode-binary-streams/lists"}