File tree Expand file tree Collapse file tree 4 files changed +12
-14
lines changed
lib/node_modules/@stdlib/array/same-kind-casts Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -93,14 +93,12 @@ var out = sameKindCasts( 'foo' );
93
93
var dtypes = require ( ' @stdlib/array/dtypes' );
94
94
var sameKindCasts = require ( ' @stdlib/array/same-kind-casts' );
95
95
96
- var DTYPES ;
97
- var list;
98
- var i;
99
-
100
96
// Get the list of supported array data types:
101
- DTYPES = dtypes ();
97
+ var DTYPES = dtypes ();
102
98
103
99
// Print the list of array data types to which a data type can be cast...
100
+ var list;
101
+ var i;
104
102
for ( i = 0 ; i < DTYPES .length ; i++ ) {
105
103
list = sameKindCasts ( DTYPES [ i ] );
106
104
console .log ( ' %s: %s' , DTYPES [ i ], list .join ( ' , ' ) );
@@ -141,14 +139,14 @@ for ( i = 0; i < DTYPES.length; i++ ) {
141
139
142
140
<section class =" links " >
143
141
142
+ [ @stdlib/array/dtypes ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtypes
143
+
144
144
<!-- <related-links> -->
145
145
146
146
[ @stdlib/array/convert ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/convert
147
147
148
148
[ @stdlib/array/convert-same ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/convert-same
149
149
150
- [ @stdlib/array/dtypes ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtypes
151
-
152
150
[ @stdlib/array/safe-casts ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/safe-casts
153
151
154
152
[ @stdlib/ndarray/same-kind-casts ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/same-kind-casts
Original file line number Diff line number Diff line change 9
9
10
10
Parameters
11
11
----------
12
- dtype: string (optional)
12
+ dtype: any (optional)
13
13
Array data type.
14
14
15
15
Returns
Original file line number Diff line number Diff line change 21
21
var dtypes = require ( '@stdlib/array/dtypes' ) ;
22
22
var sameKindCasts = require ( './../lib' ) ;
23
23
24
- var DTYPES ;
25
- var list ;
26
- var i ;
27
-
28
24
// Get the list of supported array data types:
29
- DTYPES = dtypes ( ) ;
25
+ var DTYPES = dtypes ( ) ;
30
26
31
27
// Print the list of array data types to which a data type can be cast...
28
+ var list ;
29
+ var i ;
32
30
for ( i = 0 ; i < DTYPES . length ; i ++ ) {
33
31
list = sameKindCasts ( DTYPES [ i ] ) ;
34
32
console . log ( '%s: %s' , DTYPES [ i ] , list . join ( ', ' ) ) ;
Original file line number Diff line number Diff line change 22
22
23
23
var objectKeys = require ( '@stdlib/utils/keys' ) ;
24
24
var hasOwnProp = require ( '@stdlib/assert/has-own-property' ) ;
25
+ var resolve = require ( '@stdlib/strided/base/dtype-resolve-str' ) ;
25
26
var SAME_KIND_CASTS = require ( './same_kind_casts.json' ) ;
26
27
27
28
@@ -106,7 +107,7 @@ function generateTable() {
106
107
/**
107
108
* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind".
108
109
*
109
- * @param {string } [dtype] - array data type
110
+ * @param {* } [dtype] - array data type value
110
111
* @returns {(Object|StringArray|null) } list of array data types or null
111
112
*
112
113
* @example
@@ -121,6 +122,7 @@ function sameKindCasts( dtype ) {
121
122
// Lazily generate table...
122
123
TABLE = generateTable ( ) ;
123
124
}
125
+ dtype = resolve ( dtype ) ;
124
126
if ( hasOwnProp ( TABLE , dtype ) ) {
125
127
return TABLE [ dtype ] . slice ( ) ;
126
128
}
You can’t perform that action at this time.
0 commit comments