X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fgrunt-legacy-util%2Fnode_modules%2Flodash%2Ftimes.js;fp=node_modules%2Fgrunt-legacy-util%2Fnode_modules%2Flodash%2Ftimes.js;h=b7ede33bd42d18d4702a25c68674e1b8c8cc559e;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/grunt-legacy-util/node_modules/lodash/times.js b/node_modules/grunt-legacy-util/node_modules/lodash/times.js new file mode 100644 index 000000000..b7ede33bd --- /dev/null +++ b/node_modules/grunt-legacy-util/node_modules/lodash/times.js @@ -0,0 +1,50 @@ +var baseTimes = require('./_baseTimes'), + toFunction = require('./_toFunction'), + toInteger = require('./toInteger'); + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH = 4294967295; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * Invokes the iteratee function `n` times, returning an array of the results + * of each invocation. The iteratee is invoked with one argument; (index). + * + * @static + * @memberOf _ + * @category Util + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of results. + * @example + * + * _.times(3, String); + * // => ['0', '1', '2'] + * + * _.times(4, _.constant(true)); + * // => [true, true, true, true] + */ +function times(n, iteratee) { + n = toInteger(n); + if (n < 1 || n > MAX_SAFE_INTEGER) { + return []; + } + var index = MAX_ARRAY_LENGTH, + length = nativeMin(n, MAX_ARRAY_LENGTH); + + iteratee = toFunction(iteratee); + n -= MAX_ARRAY_LENGTH; + + var result = baseTimes(length, iteratee); + while (++index < n) { + iteratee(index); + } + return result; +} + +module.exports = times;