0.3.2 • Published 11 years ago
randstream v0.3.2
RANDSTREAM
A stream that sprays out random bytes at whoever's read()-ing it or listening to
its data.  The implementation is surprisingly trivial thanks to
isaacs/readable-stream so I didn't have any tests but you should just take a good
look at the code if you are not sure.
API
The exported RandStream class accepts a single option hash which is passed along as an
option to the inherited Readable class with an exception of a few extra parameters:
var RandStream = require('randstream');
var firehose = new RandStream(
  { mode: 'alpha'
  , defaultSize: 4096
  });
firehose.pipe(process.stdout);The mode option maybe one of the following value:
- 0- A zero-filled streams. Essentially no longer random.
- 01- A zero-one stream. Useful to use as test streams that is a bit less boring :p
- random- Default mode, using- crypto.randomBytesto generate data. The buffer is then pushed any reading clients untouched.
- pseudo- Uses- crypto.pseudoRandomBytesinstead.
- alpha- A stream of lowercase alphabets. Useful if you want to see the bytes being piped. The original sequence is generated using- crypto.randomBytes.
- num- Like- alphabut generate a stream of digits.
- pregenerated- Like- randombut reads from a random start position in a pregenerated buffer of data.
The defaultSize is the default size of the buffer to allocate when the underlying
_read implementation is not given a size.
CLI
This module can also be used from the command line if you install globally with -g
$ npm install -g randstream
$ rand | hexdump -vor with different mode and throttling rate:
$ rand alpha 16
mcrqijnorspunxrkkeyehapnpfgqfbkzjfvkctxfdkm^CLICENSE
public domain.