00001 var baseTimes = require('./_baseTimes'),
00002 castFunction = require('./_castFunction'),
00003 toInteger = require('./toInteger');
00004
00006 var MAX_SAFE_INTEGER = 9007199254740991;
00007
00009 var MAX_ARRAY_LENGTH = 4294967295;
00010
00011
00012 var nativeMin = Math.min;
00013
00033 function times(n, iteratee) {
00034 n = toInteger(n);
00035 if (n < 1 || n > MAX_SAFE_INTEGER) {
00036 return [];
00037 }
00038 var index = MAX_ARRAY_LENGTH,
00039 length = nativeMin(n, MAX_ARRAY_LENGTH);
00040
00041 iteratee = castFunction(iteratee);
00042 n -= MAX_ARRAY_LENGTH;
00043
00044 var result = baseTimes(length, iteratee);
00045 while (++index < n) {
00046 iteratee(index);
00047 }
00048 return result;
00049 }
00050
00051 module.exports = times;