Skip to content

Commit 0ffbfe3

Browse files
committed
Auto-generated commit
1 parent 64f5726 commit 0ffbfe3

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-03-23)
7+
## Unreleased (2026-03-30)
88

99
<section class="commits">
1010

1111
### Commits
1212

1313
<details>
1414

15+
- [`9d06cf9`](https://github.com/stdlib-js/stdlib/commit/9d06cf9a66cd23f2640a7b20652748152cb90ee9) - **refactor:** perform explicit dtype validation _(by Athan Reines)_
1516
- [`8452bac`](https://github.com/stdlib-js/stdlib/commit/8452bacd27b9cb267bc12c5d87d0e80fb4955f4d) - **bench:** refactor to use string interpolation in `array/zeros-like` [(#10349)](https://github.com/stdlib-js/stdlib/pull/10349) _(by Shubham)_
1617

1718
</details>
@@ -24,8 +25,9 @@
2425

2526
### Contributors
2627

27-
A total of 1 person contributed to this release. Thank you to this contributor:
28+
A total of 2 people contributed to this release. Thank you to the following contributors:
2829

30+
- Athan Reines
2931
- Shubham
3032

3133
</section>

dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@
2020

2121
// MODULES //
2222

23-
var format = require( '@stdlib/string-format' );
23+
var contains = require( '@stdlib/array-base-assert-contains' ).factory;
2424
var dtype = require( '@stdlib/array-dtype' );
2525
var zeros = require( '@stdlib/array-zeros' );
26+
var dtypes = require( '@stdlib/array-dtypes' );
27+
var join = require( '@stdlib/array-base-join' );
28+
var format = require( '@stdlib/string-format' );
29+
30+
31+
// VARIABLES //
32+
33+
var DTYPES = dtypes( 'numeric_and_generic' );
34+
var isValidDType = contains( DTYPES );
2635

2736

2837
// MAIN //
@@ -51,6 +60,11 @@ function zerosLike( x ) {
5160
}
5261
if ( arguments.length > 1 ) {
5362
dt = arguments[ 1 ];
63+
if ( !isValidDType( dt ) ) {
64+
throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) );
65+
}
66+
} else if ( !isValidDType( dt ) ) {
67+
throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) );
5468
}
5569
return zeros( x.length, dt );
5670
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40+
"@stdlib/array-base-assert-contains": "^0.2.3",
41+
"@stdlib/array-base-join": "^0.1.2",
4042
"@stdlib/array-dtype": "^0.3.1",
43+
"@stdlib/array-dtypes": "^0.4.1",
4144
"@stdlib/array-zeros": "^0.2.3",
4245
"@stdlib/string-format": "^0.2.3",
4346
"@stdlib/types": "^0.4.3",
@@ -46,7 +49,6 @@
4649
"devDependencies": {
4750
"@stdlib/array-complex128": "^0.3.2",
4851
"@stdlib/array-complex64": "^0.3.2",
49-
"@stdlib/array-dtypes": "^0.4.1",
5052
"@stdlib/array-float32": "^0.2.3",
5153
"@stdlib/array-float64": "^0.2.3",
5254
"@stdlib/array-int16": "^0.2.3",

0 commit comments

Comments
 (0)