https://github.com/ksm2/isomorphic-streams
Isomorphic WHATWG Streams API package for browser and Node.js
https://github.com/ksm2/isomorphic-streams
isomorphic-javascript web-streams whatwg-streams
Last synced: 8 months ago
JSON representation
Isomorphic WHATWG Streams API package for browser and Node.js
- Host: GitHub
- URL: https://github.com/ksm2/isomorphic-streams
- Owner: ksm2
- License: mit
- Created: 2021-11-26T20:43:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-07T14:56:41.000Z (over 3 years ago)
- Last Synced: 2025-06-09T09:02:58.991Z (9 months ago)
- Topics: isomorphic-javascript, web-streams, whatwg-streams
- Language: TypeScript
- Homepage:
- Size: 93.8 KB
- Stars: 14
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# isomorphic-streams
[](https://github.com/ksm2/isomorphic-streams/actions/workflows/node.js.yml)
[](https://www.npmjs.com/package/isomorphic-streams)
[](https://opensource.org/licenses/MIT)
[](https://github.com/ksm2/isomorphic-streams/blob/main/index.d.ts)
> Isomorphic [WHATWG Streams API] package for browser and Node.js
This package has
- **zero dependencies**
- provides **TypeScript typings**
- supports `ReadableStream`, `WritableStream` and `TransformStream`
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Install
Use either
yarn add isomorphic-streams
or
npm install isomorphic-streams
## Usage
**In the browser:** Instead of using the global `ReadbaleStream` or `window.ReadableStream`, import from this package instead.
**In Node.js:** Instead of importing `node:stream/web` or requiring `stream/web`, import from this package instead.
The following code will work in both Node.js and the browser:
```js
import { ReadableStream } from "isomorphic-streams";
const SECOND = 1000;
const stream = new ReadableStream({
start(controller) {
setInterval(() => {
controller.enqueue(Date.now());
}, SECOND);
},
});
for await (const value of stream) {
console.log(value);
}
```
[More examples][examples]
## Contributing
This project is open to feedback and contributions, please open an issue.
`isomorphic-streams` follows the [Contributor Covenant] Code of Conduct.
## License
MIT © 2021 Konstantin Möllers, see [LICENSE].
[whatwg streams api]: https://streams.spec.whatwg.org/
[license]: https://github.com/ksm2/isomorphic-streams/blob/main/LICENSE
[contributor covenant]: https://github.com/ksm2/isomorphic-streams/blob/main/CODE_OF_CONDUCT.md
[examples]: https://github.com/ksm2/isomorphic-streams/tree/main/examples