1.0.7 • Published 7 years ago

array_rand v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

array_rand

Returns specified number of random objects from the array. Given an array, this module will fetch the specified number of random elements within a range in the array.

Run Status

Installing

npm install array_rand

Functions

The array_rand module has two versions of the functions :

Async version

getRandomObjectsInRange(array, count, startIndex, endIndex, callback)

Sync version

getRandomObjectsInRangeSync(array, count, startIndex, endIndex)

Where:

array - The array used
count - The count of random objects that you need from the array
startIndex - The starting index of the array
endIndex - The ending index of the array

Usage

var array_rand = require('array_rand');
var arr = [1,2,3,4,5,6];
var result = array_rand.getRandomObjectsInRangeSync(arr, 3, 1, 5);
array_rand.getRandomObjectsInRange(arr, 3, 1, 5, function(err, result) {
  // Do operation on result
});
// Results any three elements from the array "arr" in the given range
1.0.7

7 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago