Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/okunishinishi/node-randomval

Node.js module to generate random value.
https://github.com/okunishinishi/node-randomval

Last synced: 2 months ago
JSON representation

Node.js module to generate random value.

Awesome Lists containing this project

README

        

randomval
==========

[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]

[bd_repo_url]: https://github.com/okunishinishi/node-randomval
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-randomval
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-randomval.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/okunishinishi/node-randomval
[bd_travis_com_shield_url]: https://api.travis-ci.com/okunishinishi/node-randomval.svg?token=
[bd_license_url]: https://github.com/okunishinishi/node-randomval/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-randomval
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-randomval.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-randomval.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-randomval
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-randomval.svg
[bd_npm_url]: http://www.npmjs.org/package/randomval
[bd_npm_shield_url]: http://img.shields.io/npm/v/randomval.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg

Generate random values.

Installation
-----

```bash
npm install randomval --save
```

Usage
----

```javascript
#!/usr/bin/env/node

const randomval = require('randomval')

// ------------------------
// Random Bool
// ------------------------
console.log(randomval.randomBool()) //-> true
console.log(randomval.randomBool()) //-> true
console.log(randomval.randomBool()) //-> true

// ------------------------
// Random Date
// ------------------------
console.log(randomval.randomDate()) //-> Mon Nov 28 2016 04:50:44 GMT+0900 (JST)
console.log(randomval.randomDate()) //-> Mon Nov 07 2016 20:27:57 GMT+0900 (JST)
console.log(randomval.randomDate()) //-> Sun Nov 27 2016 10:53:39 GMT+0900 (JST)

// ------------------------
// Random Hash
// ------------------------
console.log(randomval.randomHash()) //-> 8d2a76c0e7b04bb690c7a17bfe7d03c5
console.log(randomval.randomHash()) //-> 613a056fd107413e9b6787a6055d78ed
console.log(randomval.randomHash()) //-> bd1b3f70b4f4466d87cf0dda704936b7

// ------------------------
// Random Int
// ------------------------
console.log(randomval.randomInt()) //-> 1423455250182315
console.log(randomval.randomInt()) //-> -7677881246134615
console.log(randomval.randomInt()) //-> -380459522751636

// ------------------------
// Random
// ------------------------
console.log(randomval.random()) //-> 0.46031310883760845
console.log(randomval.random()) //-> 0.24084973502152018
console.log(randomval.random()) //-> 0.01482755843377448

```

API Guide
---------

| Signature | Description |
| ---- | ----- |
| **.random()** | Random number between 0 and 1 |
| **.randomBool()** | Random boolean. (`true` or `false`) |
| **.randomInt()** | Random integer value |
| **.randomInt(min, max)** | Random integer value in range |
| **.randomHash()** | Random hash string |
| **.randomHash(len)** | Random hash string with length |
| **.randomDate()** | Random date |
| **.randomDate(min, max)** | Random date in range |

License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-randomval/blob/master/LICENSE).

Links
------

+ [random-js][random_js_url]

[random_js_url]: https://www.npmjs.com/package/random-js