]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/node_modules/grim/node_modules/emissary/node_modules/es6-weak-map/node_modules/es5-ext/array/generate.js
5e066750b1d5baa420ac457830317654cf34493d
[rbdr/dotfiles] / atom / packages / vim-mode / node_modules / grim / node_modules / emissary / node_modules / es6-weak-map / node_modules / es5-ext / array / generate.js
1 'use strict';
2
3 var toPosInt = require('../number/to-pos-integer')
4 , value = require('../object/valid-value')
5
6 , slice = Array.prototype.slice;
7
8 module.exports = function (length/*, …fill*/) {
9 var arr, l;
10 length = toPosInt(value(length));
11 if (length === 0) return [];
12
13 arr = (arguments.length < 2) ? [undefined] :
14 slice.call(arguments, 1, 1 + length);
15
16 while ((l = arr.length) < length) {
17 arr = arr.concat(arr.slice(0, length - l));
18 }
19 return arr;
20 };