Skip to content

Commit 870a321

Browse files
committed
feat: support non-string dtype values
1 parent a8643cd commit 870a321

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

lib/node_modules/@stdlib/array/same-kind-casts/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ var out = sameKindCasts( 'foo' );
9393
var dtypes = require( '@stdlib/array/dtypes' );
9494
var sameKindCasts = require( '@stdlib/array/same-kind-casts' );
9595

96-
var DTYPES;
97-
var list;
98-
var i;
99-
10096
// Get the list of supported array data types:
101-
DTYPES = dtypes();
97+
var DTYPES = dtypes();
10298

10399
// Print the list of array data types to which a data type can be cast...
100+
var list;
101+
var i;
104102
for ( i = 0; i < DTYPES.length; i++ ) {
105103
list = sameKindCasts( DTYPES[ i ] );
106104
console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) );
@@ -141,14 +139,14 @@ for ( i = 0; i < DTYPES.length; i++ ) {
141139

142140
<section class="links">
143141

142+
[@stdlib/array/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtypes
143+
144144
<!-- <related-links> -->
145145

146146
[@stdlib/array/convert]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/convert
147147

148148
[@stdlib/array/convert-same]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/convert-same
149149

150-
[@stdlib/array/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtypes
151-
152150
[@stdlib/array/safe-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/safe-casts
153151

154152
[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/same-kind-casts

lib/node_modules/@stdlib/array/same-kind-casts/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Parameters
1111
----------
12-
dtype: string (optional)
12+
dtype: any (optional)
1313
Array data type.
1414

1515
Returns

lib/node_modules/@stdlib/array/same-kind-casts/examples/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
var dtypes = require( '@stdlib/array/dtypes' );
2222
var sameKindCasts = require( './../lib' );
2323

24-
var DTYPES;
25-
var list;
26-
var i;
27-
2824
// Get the list of supported array data types:
29-
DTYPES = dtypes();
25+
var DTYPES = dtypes();
3026

3127
// Print the list of array data types to which a data type can be cast...
28+
var list;
29+
var i;
3230
for ( i = 0; i < DTYPES.length; i++ ) {
3331
list = sameKindCasts( DTYPES[ i ] );
3432
console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) );

lib/node_modules/@stdlib/array/same-kind-casts/lib/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var objectKeys = require( '@stdlib/utils/keys' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25+
var resolve = require( '@stdlib/strided/base/dtype-resolve-str' );
2526
var SAME_KIND_CASTS = require( './same_kind_casts.json' );
2627

2728

@@ -106,7 +107,7 @@ function generateTable() {
106107
/**
107108
* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind".
108109
*
109-
* @param {string} [dtype] - array data type
110+
* @param {*} [dtype] - array data type value
110111
* @returns {(Object|StringArray|null)} list of array data types or null
111112
*
112113
* @example
@@ -121,6 +122,7 @@ function sameKindCasts( dtype ) {
121122
// Lazily generate table...
122123
TABLE = generateTable();
123124
}
125+
dtype = resolve( dtype );
124126
if ( hasOwnProp( TABLE, dtype ) ) {
125127
return TABLE[ dtype ].slice();
126128
}

0 commit comments

Comments
 (0)