Skip to content

mock-end/random-binary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

random-binary

Return a random binary number.

MIT License

build:? coverage:?

Install

$ npm install --save random-binary 

Usage

For more use-cases see the tests

var randomBinary = require('random-binary');

// API
// - randomBinary([bit]);
// - randomBinary([options]);

By default, the bit length is randomly between 0 and 256:

randomBinary();     
// => '11010000101111010101011010101100'

Can optionally specify a bit length and the result will be exactly that length:

randomBinary(4); // or
randomBinary({ bit: 4 });
// => '0111'

randomBinary(8); // or
randomBinary({ bit: 8 });
// => '11011111'

randomBinary(16); // or
randomBinary({ bit: 16 });
// => '0101100001110000'

Note: the bit should between 0 and 256.

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

About

Return a random binary number.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published