Skip to content

mock-end/random-utility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

random-utility

Javascript utilities for generating random data.

MIT License

build:? coverage:?

Install

$ npm install --save random-utility

Usage

var random = require('random-utility');

random.int();
// => 9527

random.char();
// => 'G'

API

Method Description Document
int([min, max]) Generate a random integer. Link
natural([min, max]) Generate a random natural number. Link
float([min, max, precision]) Generate a random float. Link
bool([seed1, seed2, ref]) Generate a random boolean (true/false). Link
char([pool]) Generate a random character. Link
string([pool, length]) Generate a random string. Link
binary([bit]) Generate a random binary number. Link
octal([min, max]) Generate a random octal. Link
hex([min, max]) Generate a random hexadecimal number. Link
dx() Generate a number between 1 and x,
where x is 5 10, 20, 50, 100, 200, 500 and 1000.
pickOne(arr) Randomly sampling a item from an array. Link
pickSome(arr[, options]) Randomly sampling some items from an array. Link
shuffle(arr) Randomize the order of the elements in array or array-like object. Link
index([max]) Generate a random array-like index. Link
pickKey(obj) Randomly sampling a key from an object. Link
pickKeys(obj) Randomly sampling some keys from an object. Link
pickProp(obj) Randomly sampling a property from an object. Link
pickProps(obj) Randomly sampling some properties from an object. Link
date([min, max]) Generate a random date. Link
color() Generate a random color. Link
uuid([prefix]) Generate a random uuid. Link
id([length]) Generate a random ID. Link
lang() Return a random language name. Link
zipcode() Generate a random chinese zipcode. Link
mobile() Return a random Chinese mobile phone number. Link
tld() Return a random tld. Link
domain([level, tld]) Generate a random domain name. Link
email([domain]) Generate a random email address. Link
url([protocol, query, hash]) Generate a random url. Link
ipv4([schema, options]) Generate a random ipv4 address. Link
ipv6([schema, options]) Generate a random ipv6 address. Link
maleFirstName() Return a random male first-name.
femaleFirstName() Return a random female first-name.
lastName() Return a random last-name.
name([middleName]) Return a random name.
world([min, max]) Generate a random world. Link
sentence([min, max]) Generate a random sentence. Link
title([min, max]) Generate a random title. Link
paragraph([min, max]) Generate a random paragraph. Link

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

About

Javascript utilities for generating random data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published