Skip to content

Commit a42d81c

Browse files
committed
Auto-generated commit
1 parent 8862eb3 commit a42d81c

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

.github/.keepalive

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

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2026-03-30)
8+
9+
<section class="commits">
10+
11+
### Commits
12+
13+
<details>
14+
15+
- [`68ef3ce`](https://github.com/stdlib-js/stdlib/commit/68ef3cef76a8f6080cf8cf4171b9a449c969315b) - **refactor:** perform explicit dtype validation _(by Athan Reines)_
16+
17+
</details>
18+
19+
</section>
20+
21+
<!-- /.commits -->
22+
23+
<section class="contributors">
24+
25+
### Contributors
26+
27+
A total of 1 person contributed to this release. Thank you to this contributor:
28+
29+
- Athan Reines
30+
31+
</section>
32+
33+
<!-- /.contributors -->
34+
35+
</section>
36+
37+
<!-- /.release -->
38+
539
<section class="release" id="v0.2.2">
640

741
## 0.2.2 (2026-02-08)

dist/index.js

Lines changed: 1 addition & 1 deletion
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020

2121
// MODULES //
2222

23+
var contains = require( '@stdlib/array-base-assert-contains' ).factory;
2324
var dtype = require( '@stdlib/array-dtype' );
2425
var full = require( '@stdlib/array-full' );
2526
var Complex128 = require( '@stdlib/complex-float64-ctor' );
2627
var Complex64 = require( '@stdlib/complex-float32-ctor' );
28+
var dtypes = require( '@stdlib/array-dtypes' );
29+
var join = require( '@stdlib/array-base-join' );
2730
var format = require( '@stdlib/string-format' );
2831

2932

3033
// VARIABLES //
3134

3235
var Z128 = new Complex128( 1.0, 0.0 );
3336
var Z64 = new Complex64( 1.0, 0.0 );
37+
var DTYPES = dtypes( 'numeric_and_generic' );
38+
var isValidDType = contains( DTYPES );
3439

3540

3641
// MAIN //
@@ -62,6 +67,11 @@ function onesLike( x ) {
6267
}
6368
if ( arguments.length > 1 ) {
6469
dt = arguments[ 1 ];
70+
if ( !isValidDType( dt ) ) {
71+
throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) );
72+
}
73+
} else if ( !isValidDType( dt ) ) {
74+
throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) );
6575
}
6676
if ( dt === 'complex128' ) {
6777
v = Z128;

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-full": "^0.3.1",
4245
"@stdlib/complex-float32-ctor": "^0.1.1",
4346
"@stdlib/complex-float64-ctor": "^0.1.2",
@@ -48,7 +51,6 @@
4851
"devDependencies": {
4952
"@stdlib/array-complex128": "^0.3.2",
5053
"@stdlib/array-complex64": "^0.3.2",
51-
"@stdlib/array-dtypes": "^0.4.1",
5254
"@stdlib/array-float32": "^0.2.3",
5355
"@stdlib/array-float64": "^0.2.3",
5456
"@stdlib/array-int16": "^0.2.3",

0 commit comments

Comments
 (0)