You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
288 B
JavaScript
16 lines
288 B
JavaScript
6 years ago
|
'use strict';
|
||
|
module.exports = function (item, n) {
|
||
|
var ret = new Array(n);
|
||
|
var isFn = typeof item === 'function';
|
||
|
|
||
|
if (!isFn && typeof ret.fill === 'function') {
|
||
|
return ret.fill(item);
|
||
|
}
|
||
|
|
||
|
for (var i = 0; i < n; i++) {
|
||
|
ret[i] = isFn ? item(i, n, ret) : item;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
};
|