random-binary
Return a random binary number.
Install
$ npm install --save random-binary
Usage
For more use-cases see the tests
var randomBinary = ; // API// - randomBinary([bit]);// - randomBinary([options]);
By default, the bit length is randomly between 0
and 256
:
; // => 11010000101111010101011010101100
Can optionally specify a bit length and the result will be exactly that length:
; // or;// => 0111 ; // or;// => 11011111 ; // or;// => 0101100001110000
Note: the bit
should between 0
and 256
.
Related
- random-integral - Return a random integer.
- random-natural - Return a random natural number.
- random-decimal - Return a random decimal.
- random-floating - Return a random floating point number.
- random-index - Return a random array-like index.
- random-octal - Return a random octal number.
- random-hexadecimal - Return a random hexadecimal number.
- random-unicode - Return a random unicode.
- random-bool - Return a random boolean (true/false).
- random-char - Return a random char.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.