Bones/node_modules/filled-array/index.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

16 lines
288 B
JavaScript

'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;
};