random-fragment

0.3.2 • Public • Published

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]
});

Readme

Keywords

Package Sidebar

Install

npm i random-fragment

Weekly Downloads

0

Version

0.3.2

License

MIT

Unpacked Size

6.23 kB

Total Files

7

Last publish

Collaborators

  • hzy-xiaoke