Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/randplus/randplus
A package that add functions for random.
https://github.com/randplus/randplus
addon extension nodejs npm plus random
Last synced: about 12 hours ago
JSON representation
A package that add functions for random.
- Host: GitHub
- URL: https://github.com/randplus/randplus
- Owner: randplus
- Created: 2024-05-23T23:39:26.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T14:34:41.000Z (13 days ago)
- Last Synced: 2024-10-25T18:29:57.496Z (12 days ago)
- Topics: addon, extension, nodejs, npm, plus, random
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/randplus
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# randplus
A package that add functions for random.## Usage
```js
const random = require('randplus');console.log(random.random()); // 0 ~ 1 (!= 1)
console.log(random.random(true)); // 0 ~ 1 (== 1)
console.log(random.number(1, 10)); // 1 ~ 10
console.log(random.number(1, 10, false)); // 1 ~ 10 (!= 10)
console.log(random.integer(1, 10)); // 1 ~ 10
console.log(random.integer(1, 10, false)); // 1 ~ 10 (!= 10)
console.log(random.boolean()); // true or false
console.log(random.array(['Hello', 'World!'])); // 'Hello' or 'World!'
console.log(random.buffer()); //
console.log(random.buffer(16)); // ''
console.log(random.string(3)); // '000' ~ 'ZZZ'
console.log(random.string('abc', 3)); // 'aaa' ~ 'ccc'
console.log(random.string(['01', '02', '03'], 3)); // '010101' ~ '030303'
console.log(random.shuffle('abcdef')); // 'cfeadb'
console.log(random.shuffle(['a', 'b', 'c', 'd', 'e', 'f'])); // ['c', 'f', 'e', 'a', 'd', 'b']
console.log(random.color()); // '000000' ~ 'ffffff'
console.log(random.color('hex')); // '000000' ~ 'ffffff'
console.log(random.color('hex', { prefix: '#' })); // '#000000' ~ '#ffffff'
console.log(random.color('rgb')); // [0, 0, 0] ~ [255, 255, 255]
console.log(random.color('word')); // 'limegreen'
console.log(random.color('word', { language: 'ja' })); // '鉄色'
console.log(random.color.hex()); // '000000' ~ 'ffffff'
console.log(random.color.hex('#')); // '000000' ~ 'ffffff'
console.log(random.color.rgb()); // [0, 0, 0] ~ [255, 255, 255]
console.log(random.color.word()); // 'limegreen'
console.log(random.color.word('cn')); // '紫磨金'
```