Skip to content

Commit b60d327

Browse files
committed
feat: add support for non-string data types
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8e7dc95 commit b60d327

File tree

2 files changed

+17
-4
lines changed
  • lib/node_modules/@stdlib/ndarray/base/assert/is-index-data-type

2 files changed

+17
-4
lines changed

lib/node_modules/@stdlib/ndarray/base/assert/is-index-data-type/lib/main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2424
var dtypes = require( '@stdlib/ndarray/dtypes' );
2525

2626

27+
// VARIABLES //
28+
29+
var isDataType = contains( dtypes( 'index' ) );
30+
31+
2732
// MAIN //
2833

2934
/**
3035
* Tests whether an input value is a supported ndarray index data type.
3136
*
32-
* @name isIndexDataType
33-
* @type {Function}
3437
* @param {*} v - value to test
3538
* @returns {boolean} boolean indicating whether an input value is a supported ndarray index data type
3639
*
@@ -71,7 +74,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
7174
* bool = isIndexDataType( 'foo' );
7275
* // returns false
7376
*/
74-
var isIndexDataType = contains( dtypes( 'index' ) );
77+
function isIndexDataType( v ) {
78+
return isDataType( String( v ) );
79+
}
7580

7681

7782
// EXPORTS //

lib/node_modules/@stdlib/ndarray/base/assert/is-index-data-type/test/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var DataType = require( '@stdlib/ndarray/dtype-ctor' );
2425
var isIndexDataType = require( './../lib' );
2526

2627

@@ -41,7 +42,12 @@ tape( 'the function returns `true` if provided a supported ndarray index data ty
4142
'bool',
4243
'int32',
4344
'uint8',
44-
'generic'
45+
'generic',
46+
47+
new DataType( 'bool' ),
48+
new DataType( 'int32' ),
49+
new DataType( 'uint8' ),
50+
new DataType( 'generic' )
4551
];
4652
for ( i = 0; i < values.length; i++ ) {
4753
bool = isIndexDataType( values[ i ] );
@@ -68,6 +74,8 @@ tape( 'the function returns `false` if not provided a supported ndarray index da
6874
'uint32',
6975
'uint8c',
7076

77+
new DataType( 'binary' ),
78+
7179
// Unsupported dtypes:
7280
'float',
7381
'int',

0 commit comments

Comments
 (0)