https://github.com/hugomrdias/iso-random-stream
Random bytes stream for node and browser
https://github.com/hugomrdias/iso-random-stream
browser bytes isomorphic node random stream
Last synced: about 1 month ago
JSON representation
Random bytes stream for node and browser
- Host: GitHub
- URL: https://github.com/hugomrdias/iso-random-stream
- Owner: hugomrdias
- License: mit
- Created: 2018-09-18T16:07:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T06:31:08.000Z (over 2 years ago)
- Last Synced: 2025-04-25T01:09:49.883Z (about 2 months ago)
- Topics: browser, bytes, isomorphic, node, random, stream
- Language: JavaScript
- Homepage:
- Size: 555 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 18
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: license
Awesome Lists containing this project
README
# iso-random-stream [](https://www.npmjs.com/package/iso-random-stream) [](https://www.npmjs.com/package/iso-random-stream) [](https://www.npmjs.com/package/iso-random-stream) [](https://github.com/hugomrdias/iso-random-stream/actions/workflows/main.yml) [](https://codecov.io/gh/hugomrdias/iso-random-stream?branch=master)
> Random bytes stream for node and browser. Uses [crypto.randomBytes(size[, callback])](https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback) in node and [Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) in the browser. We use Buffer to keep the interfaces and returns values consistent, so make sure your bundler includes `buffer` in the browser.
## Install
```
$ npm install iso-random-stream
```## Usage
```js
const { randomStream } = require('iso-random-stream')randomStream('100').pipe(process.stdout)
```## API
### randomStream(size)
Returns a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams). By default, it produces infinite data.
#### size
Type: `number`
Default: `Infinity`Number of random bytes to produce.
## License
MIT © [Hugo Dias](http://hugodias.me)