File tree 4 files changed +7
-15
lines changed
lib/node_modules/@stdlib/ndarray/next-dtype
4 files changed +7
-15
lines changed Original file line number Diff line number Diff line change 11
11
12
12
Parameters
13
13
----------
14
- dtype: string (optional)
15
- ndarray data type.
14
+ dtype: any (optional)
15
+ ndarray data type value .
16
16
17
17
Returns
18
18
-------
Original file line number Diff line number Diff line change 27
27
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
28
28
* - If provided an unrecognized data type, the function returns `null`.
29
29
*
30
- * @param dtype - ndarray data type
30
+ * @param dtype - ndarray data type value
31
31
* @returns next larger data type(s) or null
32
32
*
33
33
* @example
34
34
* var dt = nextDataType( 'float32' );
35
35
* // returns 'float64'
36
36
*/
37
- declare function nextDataType ( dtype ?: string ) : any ;
37
+ declare function nextDataType ( dtype ?: any ) : any ;
38
38
39
39
40
40
// EXPORTS //
Original file line number Diff line number Diff line change @@ -28,16 +28,6 @@ import nextDataType = require( './index' );
28
28
nextDataType ( 'float' ) ; // $ExpectType any
29
29
}
30
30
31
- // The function does not compile if provided a value other than a string...
32
- {
33
- nextDataType ( 123 ) ; // $ExpectError
34
- nextDataType ( true ) ; // $ExpectError
35
- nextDataType ( false ) ; // $ExpectError
36
- nextDataType ( null ) ; // $ExpectError
37
- nextDataType ( { } ) ; // $ExpectError
38
- nextDataType ( ( x : number ) : number => x ) ; // $ExpectError
39
- }
40
-
41
31
// The function does not compile if provided more than one argument...
42
32
{
43
33
nextDataType ( 'float32' , 123 ) ; // $ExpectError
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 resolveStr = require ( '@stdlib/ndarray/base/dtype-resolve-str' ) ;
25
26
var NEXT_DTYPES = require ( './next_dtypes.json' ) ;
26
27
27
28
@@ -54,7 +55,7 @@ function generateTable() {
54
55
/**
55
56
* Returns the next larger ndarray data type of the same kind.
56
57
*
57
- * @param {string } [dtype] - ndarray data type
58
+ * @param {* } [dtype] - ndarray data type value
58
59
* @returns {(Object|string|integer|null) } next larger data type(s) or null
59
60
*
60
61
* @example
@@ -65,6 +66,7 @@ function nextDataType( dtype ) {
65
66
if ( arguments . length === 0 ) {
66
67
return generateTable ( ) ;
67
68
}
69
+ dtype = resolveStr ( dtype ) ;
68
70
if ( hasOwnProp ( NEXT_DTYPES , dtype ) ) {
69
71
return NEXT_DTYPES [ dtype ] ;
70
72
}
You can’t perform that action at this time.
0 commit comments