https://github.com/eces/random-sample-value
Return a value randomly from given values. rsv stands for Random Sample Value.
https://github.com/eces/random-sample-value
Last synced: 10 months ago
JSON representation
Return a value randomly from given values. rsv stands for Random Sample Value.
- Host: GitHub
- URL: https://github.com/eces/random-sample-value
- Owner: eces
- Created: 2017-10-14T14:52:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-14T15:12:01.000Z (over 8 years ago)
- Last Synced: 2025-08-17T08:55:06.464Z (10 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://badge.fury.io/js/rsv)
# Sample values, not simple value.
`sample-value` returns a value randomly from given values.
## Usage
Good for build strong test including eventually invalid values.
`npm install rsv`
```js
// ONLY the example using es6 syntax.
const should_fail = require('rsv')(null, '', 'INVALID', false)
// returns null OR '' OR 'INVALID' OR false
const users = [
{age: 26},
{age: 19},
{age: 32},
{age: 43},
{age: 113},
{age: -1},
]
const user = require('rsv')(...users)
// returns any object from users array.
```
## Test
`npm test`
Useful examples at [test.js](https://github.com/eces/random-sample-value/blob/master/test.js).