3.0.4 • Published 6 years ago

randomly v3.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

npm Build Status Build status codecov Known Vulnerabilities Greenkeeper badge

Randomly

Randomly generate and sort data.

Installation

Run npm install --save randomly to add randomly to your project.

API Reference

randomly.string(length) ⇒ string

Creates a random string.

Kind: static method of randomly
Returns: string - The random string.
Throws:

  • TypeError Argument length must be a number
  • RangeError Argument length must be greater than or equal to 0
ParamTypeDescription
lengthnumberThe desired string length.

randomly.int(min, max) ⇒ number

Creates a random number within a range.

Kind: static method of randomly
Returns: number - The random number.
Throws:

  • TypeError Argument min must be a number
  • TypeError Argument max must be a number
ParamTypeDescription
minnumberThe lower bound.
maxnumberThe upper bound.

randomly.getLowerInt(degree) ⇒ number

Calculates the smallest n-digit number.

Kind: static method of randomly
Returns: number - The smallest n-digit number.
Throws:

  • TypeError Argument degree must be a number
  • RangeError Argument degree must be greater than or equal to 0
ParamTypeDescription
degreenumberThe number of digits.

randomly.getUpperInt(degree) ⇒ number

Calculates the largest n-digit number.

Kind: static method of randomly
Returns: number - The largest n-digit number.
Throws:

  • TypeError Argument degree must be a number
  • RangeError Argument degree must be greater than or equal to 0
ParamTypeDescription
degreenumberThe number of digits.

randomly.create(type, length) ⇒ string | number | Object

Creates a random string, number or object.

Kind: static method of randomly
Returns: string | number | Object - The random string, number or object.
Throws:

  • TypeError Argument length must be a number
  • RangeError Argument length must be greater than or equal to 0
ParamTypeDescription
typefunctionThe type to create (e.g. String, Number or Object).
lengthnumberThe length (for strings and Objects) or boundary degree (for numbers).

randomly.collect(type, quantity, length) ⇒ Array.<string> | Array.<number> | Array.<Object>

Creates an array of random strings, numbers or objects.

Kind: static method of randomly
Returns: Array.<string> | Array.<number> | Array.<Object> - The array of random strings, numbers or objects.
Throws:

  • TypeError Argument quantity must be a number
  • RangeError Argument quantity must be greater than 0
  • TypeError Argument length must be a number
  • RangeError Argument length must be greater than or equal to 0
ParamTypeDescription
typefunctionThe type to create (e.g. String, Number or Object).
quantitynumberThe quantity to create.
lengthnumberThe length (for strings and Objects) or boundary degree (for numbers).

randomly.sort(array) ⇒ Array

Sorts an array in random order.

Kind: static method of randomly
Returns: Array - The sorted array.

ParamTypeDescription
arrayArrayThe array to sort.

Testing

randomly includes several unit tests. After cloning the randomly repo locally, run npm install in the project folder to install dependencies. Run npm run build to update the built library, then npm test to execute the tests.

3.0.4

6 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.0

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago