random-fragment
v0.3.2
Published
a gadget for generating random fragment
Downloads
3
Readme
random-fragment
a gadget for generating random fragment
Install
npm install random-fragment
# or
yarn add random-fragment
Usage
const randomFragment = require('random-fragment');
// Get a random integer in the specified range
// The return value type is "number"
// The default range is [0,10], that is, "min" is 0, "max" is 10
randomFragment.getRandomInt();
// Get a random floating point number in the specified range
// The return value type is "string"
// The default range is [0.0,10.0], and the number of decimal places is 1,
// that is, "min" is 0, "max" is 10, "decimals" is 1
randomFragment.getRandomFloat();
// Get elements randomly from the specified array
// You need to pass in "sourceArray", which needs to be an iterative object
// The default "times" is 1, "canRepeat" is true
randomFragment.getRandomInArray({
sourceArray: [1, 3, 5, 7, 11]
});