Skip to content

Commit 9926edb

Browse files
committed
Remove two-parameter signature
1 parent eb8c853 commit 9926edb

7 files changed

Lines changed: 32 additions & 38 deletions

File tree

lib/node_modules/@stdlib/array/filled/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ limitations under the License.
4040
var filledarray = require( '@stdlib/array/filled' );
4141
```
4242

43-
#### filledarray( value\[, dtype] )
43+
#### filledarray( \[dtype] )
4444

4545
Creates a filled array having a specified data type `dtype`.
4646

4747
```javascript
48-
var arr = filledarray( 1.0 );
48+
var arr = filledarray();
4949
// returns <Float64Array>
5050
```
5151

@@ -65,7 +65,7 @@ The function recognizes the following data types:
6565
By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument.
6666

6767
```javascript
68-
var arr = filledarray( 1, 'int32' );
68+
var arr = filledarray( 'int32' );
6969
// returns <Int32Array>
7070
```
7171

lib/node_modules/@stdlib/array/filled/docs/repl.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( value[, dtype] )
2+
{{alias}}( [dtype] )
33
Creates a filled array.
44

55
The function supports the following data types:
@@ -19,9 +19,6 @@
1919

2020
Parameters
2121
----------
22-
value: any
23-
Fill value.
24-
2522
dtype: string (optional)
2623
Data type. Default: 'float64'.
2724

@@ -34,7 +31,7 @@
3431
--------
3532
> var arr = {{alias}}()
3633
<Float64Array>
37-
> arr = {{alias}}( 1.0, 'float32' )
34+
> arr = {{alias}}( 'float32' )
3835
<Float32Array>
3936

4037

lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,19 @@ type ArrayOrTypedArray = Array<any> | TypedArray;
4545
* - `uint8c`: 8-bit unsigned integers clamped to `0-255`
4646
* - `generic`: generic JavaScript values
4747
*
48-
* @param value - fill value
4948
* @param dtype - data type (default: 'float64')
5049
* @throws must provide a recognized data type
5150
* @returns filled array
5251
*
5352
* @example
54-
* var arr = filledarray( 1.0 );
53+
* var arr = filledarray();
5554
* // returns <Float64Array>
5655
*
5756
* @example
58-
* var arr = filledarray( 1.0, 'float32' );
57+
* var arr = filledarray( 'float32' );
5958
* // returns <Float32Array>
6059
*/
61-
declare function filledarray( value: any, dtype?: string ): ArrayOrTypedArray;
60+
declare function filledarray( dtype?: string ): ArrayOrTypedArray;
6261

6362
/**
6463
* Creates a filled array having a specified `length`.

lib/node_modules/@stdlib/array/filled/docs/types/test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function next(): any {
5252

5353
// The function returns an array or typed array...
5454
{
55-
filledarray( 1.0 ); // $ExpectType ArrayOrTypedArray
56-
filledarray( 1.0, 'float32' ); // $ExpectType ArrayOrTypedArray
55+
filledarray(); // $ExpectType ArrayOrTypedArray
56+
filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray
5757

5858
filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray
5959
filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray
@@ -198,11 +198,6 @@ function next(): any {
198198
filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError
199199
}
200200

201-
// The compiler throws an error if the function is provided insufficient arguments...
202-
{
203-
filledarray(); // $ExpectError
204-
}
205-
206201
// The compiler throws an error if the function is provided too many arguments...
207202
{
208203
const buf = new ArrayBuffer( 32 );

lib/node_modules/@stdlib/array/filled/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @example
2727
* var filledarray = require( '@stdlib/array/filled' );
2828
*
29-
* var arr = filledarray( 1.0 );
29+
* var arr = filledarray();
3030
* // returns <Float64Array>
3131
*
3232
* @example

lib/node_modules/@stdlib/array/filled/lib/main.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
4343
/**
4444
* Creates a filled array.
4545
*
46-
* @param {*} value - fill value
46+
* @param {*} [value] - fill value
4747
* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer
4848
* @param {NonNegativeInteger} [byteOffset=0] - byte offset
4949
* @param {NonNegativeInteger} [length] - view length
@@ -54,7 +54,7 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
5454
* @returns {(TypedArray|Array)} array or typed array
5555
*
5656
* @example
57-
* var arr = filledarray( 1.0 );
57+
* var arr = filledarray();
5858
* // returns <Float64Array>
5959
*
6060
* @example
@@ -129,7 +129,8 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
129129
* var arr = filledarray( 1, buf, 8, 2, 'int32' );
130130
* // returns <Int32Array>[ 1, 1 ]
131131
*/
132-
function filledarray( value ) {
132+
function filledarray() {
133+
var value;
133134
var nargs;
134135
var dtype;
135136
var ctor;
@@ -141,7 +142,7 @@ function filledarray( value ) {
141142

142143
nargs = arguments.length;
143144
nargs -= 1;
144-
if ( nargs && isString( arguments[ nargs ] ) ) {
145+
if ( nargs >= 0 && isString( arguments[ nargs ] ) ) {
145146
dtype = arguments[ nargs ];
146147
nargs -= 1;
147148
} else {
@@ -152,9 +153,10 @@ function filledarray( value ) {
152153
throw new TypeError( 'invalid argument. Must provide a recognized data type. Value: `'+dtype+'`.' );
153154
}
154155
if ( dtype === 'generic' ) {
155-
if ( nargs === 0 ) {
156+
if ( nargs <= 0 ) {
156157
return [];
157158
}
159+
value = arguments[ 0 ];
158160
arg = arguments[ 1 ];
159161
if ( nargs === 1 ) {
160162
if ( isNonNegativeInteger( arg ) ) {
@@ -213,6 +215,7 @@ function filledarray( value ) {
213215
} else {
214216
arr = new ctor( arguments[1], arguments[2], arguments[3] );
215217
}
218+
value = arguments[ 0 ];
216219
if ( arr.length > 0 && value !== 0 ) { // i.e., nonzero
217220
gfill( arr.length, value, arr, 1 );
218221
}

lib/node_modules/@stdlib/array/filled/test/test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ tape( 'main export is a function', function test( t ) {
5353
t.end();
5454
});
5555

56-
tape( 'the function throws an error if provided an unrecognized data type (two arguments)', function test( t ) {
56+
tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) {
5757
var values;
5858
var i;
5959

@@ -83,7 +83,7 @@ tape( 'the function throws an error if provided an unrecognized data type (two a
8383

8484
function badValue( value ) {
8585
return function badValue() {
86-
filledarray( 1.0, value );
86+
filledarray( value );
8787
};
8888
}
8989
});
@@ -542,7 +542,7 @@ tape( 'the function returns a filled array (default)', function test( t ) {
542542

543543
expected = new Float64Array( 0 );
544544

545-
arr = filledarray( 1.0 );
545+
arr = filledarray();
546546
t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' );
547547
t.strictEqual( arr.length, 0, 'returns expected value' );
548548
t.deepEqual( arr, expected, 'returns expected value' );
@@ -556,7 +556,7 @@ tape( 'the function returns a filled array (dtype=float64)', function test( t )
556556

557557
expected = new Float64Array( 0 );
558558

559-
arr = filledarray( 1.0, 'float64' );
559+
arr = filledarray( 'float64' );
560560
t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' );
561561
t.strictEqual( arr.length, 0, 'returns expected value' );
562562
t.deepEqual( arr, expected, 'returns expected value' );
@@ -570,7 +570,7 @@ tape( 'the function returns a filled array (dtype=float32)', function test( t )
570570

571571
expected = new Float32Array( 0 );
572572

573-
arr = filledarray( 1.0, 'float32' );
573+
arr = filledarray( 'float32' );
574574
t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' );
575575
t.strictEqual( arr.length, 0, 'returns expected value' );
576576
t.deepEqual( arr, expected, 'returns expected value' );
@@ -584,7 +584,7 @@ tape( 'the function returns a filled array (dtype=int32)', function test( t ) {
584584

585585
expected = new Int32Array( 0 );
586586

587-
arr = filledarray( 1, 'int32' );
587+
arr = filledarray( 'int32' );
588588
t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' );
589589
t.strictEqual( arr.length, 0, 'returns expected value' );
590590
t.deepEqual( arr, expected, 'returns expected value' );
@@ -598,7 +598,7 @@ tape( 'the function returns a filled array (dtype=uint32)', function test( t ) {
598598

599599
expected = new Uint32Array( 0 );
600600

601-
arr = filledarray( 1, 'uint32' );
601+
arr = filledarray( 'uint32' );
602602
t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' );
603603
t.strictEqual( arr.length, 0, 'returns expected value' );
604604
t.deepEqual( arr, expected, 'returns expected value' );
@@ -612,7 +612,7 @@ tape( 'the function returns a filled array (dtype=int16)', function test( t ) {
612612

613613
expected = new Int16Array( 0 );
614614

615-
arr = filledarray( 1, 'int16' );
615+
arr = filledarray( 'int16' );
616616
t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' );
617617
t.strictEqual( arr.length, 0, 'returns expected value' );
618618
t.deepEqual( arr, expected, 'returns expected value' );
@@ -626,7 +626,7 @@ tape( 'the function returns a filled array (dtype=uint16)', function test( t ) {
626626

627627
expected = new Uint16Array( 0 );
628628

629-
arr = filledarray( 1, 'uint16' );
629+
arr = filledarray( 'uint16' );
630630
t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' );
631631
t.strictEqual( arr.length, 0, 'returns expected value' );
632632
t.deepEqual( arr, expected, 'returns expected value' );
@@ -640,7 +640,7 @@ tape( 'the function returns a filled array (dtype=int8)', function test( t ) {
640640

641641
expected = new Int8Array( 0 );
642642

643-
arr = filledarray( 1, 'int8' );
643+
arr = filledarray( 'int8' );
644644
t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' );
645645
t.strictEqual( arr.length, 0, 'returns expected value' );
646646
t.deepEqual( arr, expected, 'returns expected value' );
@@ -654,7 +654,7 @@ tape( 'the function returns a filled array (dtype=uint8)', function test( t ) {
654654

655655
expected = new Uint8Array( 0 );
656656

657-
arr = filledarray( 1, 'uint8' );
657+
arr = filledarray( 'uint8' );
658658
t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' );
659659
t.strictEqual( arr.length, 0, 'returns expected value' );
660660
t.deepEqual( arr, expected, 'returns expected value' );
@@ -668,7 +668,7 @@ tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) {
668668

669669
expected = new Uint8ClampedArray( 0 );
670670

671-
arr = filledarray( 1, 'uint8c' );
671+
arr = filledarray( 'uint8c' );
672672
t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' );
673673
t.strictEqual( arr.length, 0, 'returns expected value' );
674674
t.deepEqual( arr, expected, 'returns expected value' );
@@ -682,7 +682,7 @@ tape( 'the function returns a filled array (dtype=generic)', function test( t )
682682

683683
expected = [];
684684

685-
arr = filledarray( 1, 'generic' );
685+
arr = filledarray( 'generic' );
686686
t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' );
687687
t.strictEqual( arr.length, 0, 'returns expected value' );
688688
t.deepEqual( arr, expected, 'returns expected value' );

0 commit comments

Comments
 (0)