Skip to content

Commit de6f9cf

Browse files
committed
Auto-generated commit
1 parent cce6103 commit de6f9cf

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

.github/workflows/test_coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ jobs:
7272
env:
7373
webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }}
7474
webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }}
75-
data: '{ "coverage": ${{ steps.extract-coverage.outputs.coverage }}, "run_id": "${{ github.run_id }}" }'
75+
data: '${{ steps.extract-coverage.outputs.coverage }}'
7676
if: ${{ false }}

lib/main.js

+6-28
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ var isCollection = require( '@stdlib/assert-is-collection' );
2626
var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );
2727
var isObject = require( '@stdlib/assert-is-object' );
2828
var isFunction = require( '@stdlib/assert-is-function' );
29-
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
3029
var ctors = require( '@stdlib/array-ctors' );
3130
var gfill = require( '@stdlib/blas-ext-base-gfill' );
31+
var filled = require( '@stdlib/array-base-filled' );
3232
var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );
3333
var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );
3434

@@ -40,26 +40,6 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
4040

4141
// FUNCTIONS //
4242

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-
function filled( len, value ) {
52-
var arr;
53-
var i;
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-
return arr;
61-
}
62-
6343
/**
6444
* Creates a filled "generic" array from an iterator.
6545
*
@@ -75,12 +55,10 @@ function filledIterator( it, value ) {
7555
arr = [];
7656
while ( true ) {
7757
v = it.next();
78-
if ( hasOwnProp( v, 'value' ) ) {
79-
arr.push( value );
80-
}
8158
if ( v.done ) {
8259
break;
8360
}
61+
arr.push( value );
8462
}
8563
return arr;
8664
}
@@ -211,7 +189,7 @@ function filledarray() {
211189
len = arg.length;
212190
}
213191
if ( len !== void 0 ) {
214-
return filled( len, value );
192+
return filled( value, len );
215193
}
216194
if ( isArrayBuffer( arg ) ) {
217195
throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );
@@ -238,16 +216,16 @@ function filledarray() {
238216
if ( nargs <= 0 ) {
239217
return new ctor( 0 );
240218
}
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.
241220
if ( nargs === 1 ) {
242221
arr = new ctor( arguments[1] );
243222
} else if ( nargs === 2 ) {
244223
arr = new ctor( arguments[1], arguments[2] );
245224
} else {
246225
arr = new ctor( arguments[1], arguments[2], arguments[3] );
247226
}
248-
value = arguments[ 0 ];
249-
if ( arr.length > 0 && value !== 0 ) { // we only need to fill a typed array if the fill value isn't zero, as typed arrays are always zero-initialized
250-
gfill( arr.length, value, arr, 1 );
227+
if ( arr.length > 0 ) {
228+
gfill( arr.length, arguments[ 0 ], arr, 1 );
251229
}
252230
return arr;
253231
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40+
"@stdlib/array-base-filled": "^0.0.x",
4041
"@stdlib/array-ctors": "^0.0.x",
4142
"@stdlib/assert-has-iterator-symbol-support": "^0.0.x",
42-
"@stdlib/assert-has-own-property": "^0.0.x",
4343
"@stdlib/assert-is-arraybuffer": "^0.0.x",
4444
"@stdlib/assert-is-collection": "^0.0.x",
4545
"@stdlib/assert-is-function": "^0.0.x",

0 commit comments

Comments
 (0)