randomval
Version:
Generate random values.
166 lines (109 loc) • 4.63 kB
Markdown
randomval
==========
<!---
This file is generated by ape-tmpl. Do not update manually.
--->
<!-- Badge Start -->
<a name="badges"></a>
[![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
<!-- Badge End -->
<!-- Description Start -->
<a name="description"></a>
Generate random values.
<!-- Description End -->
<!-- Sections Start -->
<a name="sections"></a>
<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->
<a name="section-doc-guides-01-installation-md"></a>
Installation
-----
```bash
npm install randomval --save
```
<!-- Section from "doc/guides/01.Installation.md.hbs" End -->
<!-- Section from "doc/guides/02.Usage.md.hbs" Start -->
<a name="section-doc-guides-02-usage-md"></a>
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
```
<!-- Section from "doc/guides/02.Usage.md.hbs" End -->
<!-- Section from "doc/guides/03.API Guide.md.hbs" Start -->
<a name="section-doc-guides-03-a-p-i-guide-md"></a>
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 |
<!-- Section from "doc/guides/03.API Guide.md.hbs" End -->
<!-- Sections Start -->
<!-- LICENSE Start -->
<a name="license"></a>
License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-randomval/blob/master/LICENSE).
<!-- LICENSE End -->
<!-- Links Start -->
<a name="links"></a>
Links
------
+ [random-js][random_js_url]
[random_js_url]: https://www.npmjs.com/package/random-js
<!-- Links End -->