Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/okunishinishi/node-randomval
- Owner: okunishinishi
- License: mit
- Created: 2015-08-23T08:16:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-30T14:57:52.000Z (over 8 years ago)
- Last Synced: 2024-10-12T16:54:06.332Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/randomval
- Size: 41 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.svgGenerate random values.
Installation
-----```bash
npm install randomval --save
```Usage
----```javascript
#!/usr/bin/env/nodeconst 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