Comparing version 0.0.7 to 0.0.8
0.0.8 / 2013-05-06 | ||
================== | ||
* add randomSlice() fixed #1 | ||
0.0.7 / 2013-04-17 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -110,2 +110,23 @@ /*! | ||
/** | ||
* Array random slice with items count. | ||
* @param {Array} arr | ||
* @param {Number} num, number of sub items. | ||
* @return {Array} | ||
*/ | ||
exports.randomSlice = function (arr, num) { | ||
if (!num || num >= arr.length) { | ||
return arr.slice(); | ||
} | ||
var index = Math.floor(Math.random() * arr.length); | ||
var a = []; | ||
for (var i = 0, j = index; i < num; i++) { | ||
a.push(arr[j++]); | ||
if (j === arr.length) { | ||
j = 0; | ||
} | ||
} | ||
return a; | ||
}; | ||
var MONTHS = [ | ||
@@ -112,0 +133,0 @@ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' |
{ | ||
"name": "utility", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A collection of useful utilities.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15469
320