File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
lib/node_modules/@stdlib/ndarray/base/assert/is-index-data-type Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,16 @@ var contains = require( '@stdlib/array/base/assert/contains' ).factory;
24
24
var dtypes = require ( '@stdlib/ndarray/dtypes' ) ;
25
25
26
26
27
+ // VARIABLES //
28
+
29
+ var isDataType = contains ( dtypes ( 'index' ) ) ;
30
+
31
+
27
32
// MAIN //
28
33
29
34
/**
30
35
* Tests whether an input value is a supported ndarray index data type.
31
36
*
32
- * @name isIndexDataType
33
- * @type {Function }
34
37
* @param {* } v - value to test
35
38
* @returns {boolean } boolean indicating whether an input value is a supported ndarray index data type
36
39
*
@@ -71,7 +74,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
71
74
* bool = isIndexDataType( 'foo' );
72
75
* // returns false
73
76
*/
74
- var isIndexDataType = contains ( dtypes ( 'index' ) ) ;
77
+ function isIndexDataType ( v ) {
78
+ return isDataType ( String ( v ) ) ;
79
+ }
75
80
76
81
77
82
// EXPORTS //
Original file line number Diff line number Diff line change 21
21
// MODULES //
22
22
23
23
var tape = require ( 'tape' ) ;
24
+ var DataType = require ( '@stdlib/ndarray/dtype-ctor' ) ;
24
25
var isIndexDataType = require ( './../lib' ) ;
25
26
26
27
@@ -41,7 +42,12 @@ tape( 'the function returns `true` if provided a supported ndarray index data ty
41
42
'bool' ,
42
43
'int32' ,
43
44
'uint8' ,
44
- 'generic'
45
+ 'generic' ,
46
+
47
+ new DataType ( 'bool' ) ,
48
+ new DataType ( 'int32' ) ,
49
+ new DataType ( 'uint8' ) ,
50
+ new DataType ( 'generic' )
45
51
] ;
46
52
for ( i = 0 ; i < values . length ; i ++ ) {
47
53
bool = isIndexDataType ( values [ i ] ) ;
@@ -68,6 +74,8 @@ tape( 'the function returns `false` if not provided a supported ndarray index da
68
74
'uint32' ,
69
75
'uint8c' ,
70
76
77
+ new DataType ( 'binary' ) ,
78
+
71
79
// Unsupported dtypes:
72
80
'float' ,
73
81
'int' ,
You can’t perform that action at this time.
0 commit comments