You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -40,26 +40,6 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
40
40
41
41
// FUNCTIONS //
42
42
43
-
/**
44
-
* Creates a filled "generic" array.
45
-
*
46
-
* @private
47
-
* @param {NonNegativeInteger} len - array length
48
-
* @param {*} value - fill value
49
-
* @returns {Array} filled array
50
-
*/
51
-
functionfilled(len,value){
52
-
vararr;
53
-
vari;
54
-
55
-
// Manually push elements in order to ensure "fast" elements...
56
-
arr=[];
57
-
for(i=0;i<len;i++){
58
-
arr.push(value);
59
-
}
60
-
returnarr;
61
-
}
62
-
63
43
/**
64
44
* Creates a filled "generic" array from an iterator.
65
45
*
@@ -75,12 +55,10 @@ function filledIterator( it, value ) {
75
55
arr=[];
76
56
while(true){
77
57
v=it.next();
78
-
if(hasOwnProp(v,'value')){
79
-
arr.push(value);
80
-
}
81
58
if(v.done){
82
59
break;
83
60
}
61
+
arr.push(value);
84
62
}
85
63
returnarr;
86
64
}
@@ -211,7 +189,7 @@ function filledarray() {
211
189
len=arg.length;
212
190
}
213
191
if(len!==void0){
214
-
returnfilled(len,value);
192
+
returnfilled(value,len);
215
193
}
216
194
if(isArrayBuffer(arg)){
217
195
thrownewError('invalid arguments. Creating a generic array from an ArrayBuffer is not supported.');
@@ -238,16 +216,16 @@ function filledarray() {
238
216
if(nargs<=0){
239
217
returnnewctor(0);
240
218
}
219
+
// TODO: there are possible performance improvements here. Namely, for array-like object and iterator source values, we need only know the length; otherwise, we traverse an output array twice, setting values along the way both times.
0 commit comments