Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

randplus/randplus

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

randplus

A package that add functions for random.

Teams

OTONEKO.CAT

Usage

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()); // <Buffer >
console.log(random.buffer(16)); // '<Buffer 26 bc 62 84 b0 94 5e c5 1a d5 fd 69 6f d3 78 b1>'
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')); // '紫磨金'

About

A package that add functions for random.

Topics

Resources

Stars

Watchers

Forks

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.