Skip to content

Commit 81cfd11

Browse files
committed
Add support for providing a dtype enum (or other dtype value)
1 parent 2c86afc commit 81cfd11

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

lib/node_modules/@stdlib/ndarray/base/dtype-desc/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var desc = dtypeDesc( 'foobar' );
5959
// returns null
6060
```
6161

62-
If not provided a [data type][@stdlib/ndarray/dtypes] string, the function returns an object mapping [data type][@stdlib/ndarray/dtypes] strings to descriptions.
62+
If not provided a [data type][@stdlib/ndarray/dtypes] value, the function returns an object mapping [data type][@stdlib/ndarray/dtypes] strings to descriptions.
6363

6464
```javascript
6565
var obj = dtypeDesc();

lib/node_modules/@stdlib/ndarray/base/dtype-desc/docs/repl.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
{{alias}}( [dtype] )
33
Returns the description for a specified data type.
44

5-
If not provided a string data type, the function returns an object mapping
5+
If not provided a data type value, the function returns an object mapping
66
data type strings to descriptions.
77

88
If provided an unknown/unsupported data type, the function returns `null`.
99

1010
Parameters
1111
----------
12-
dtype: string (optional)
13-
Data type.
12+
dtype: any (optional)
13+
Data type value.
1414

1515
Returns
1616
-------

lib/node_modules/@stdlib/ndarray/base/dtype-desc/docs/types/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface Table {
2929
/**
3030
* Returns the description for a provided data type.
3131
*
32-
* @param dtype - data type
32+
* @param dtype - data type value
3333
* @returns data type description
3434
*
3535
* @example
@@ -39,7 +39,7 @@ interface Table {
3939
* desc = dtypeDesc( 'generic' );
4040
* // returns '...'
4141
*/
42-
declare function dtypeDesc( dtype: string ): string | null;
42+
declare function dtypeDesc( dtype: any ): string | null;
4343

4444
/**
4545
* Returns an object mapping data type strings to descriptions.

lib/node_modules/@stdlib/ndarray/base/dtype-desc/docs/types/test.ts

-12
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,3 @@ import dtypeDesc = require( './index' );
3131
dtypeDesc( 'float64' ); // $ExpectType string | null
3232
dtypeDesc( 'generic' ); // $ExpectType string | null
3333
}
34-
35-
// The function does not compile if provided a value other than a string...
36-
{
37-
dtypeDesc( true ); // $ExpectError
38-
dtypeDesc( false ); // $ExpectError
39-
dtypeDesc( null ); // $ExpectError
40-
dtypeDesc( undefined ); // $ExpectError
41-
dtypeDesc( 5 ); // $ExpectError
42-
dtypeDesc( [] ); // $ExpectError
43-
dtypeDesc( {} ); // $ExpectError
44-
dtypeDesc( ( x: number ): number => x ); // $ExpectError
45-
}

lib/node_modules/@stdlib/ndarray/base/dtype-desc/lib/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( '@stdlib/ndarray/base/dtype-resolve-str' );
2324
var table = require( './table.js' );
2425

2526

@@ -54,7 +55,7 @@ function dtypeDesc( dtype ) {
5455
if ( TABLE === void 0 ) {
5556
TABLE = table();
5657
}
57-
return TABLE[ dtype ] || null;
58+
return TABLE[ resolve( dtype ) ] || null;
5859
}
5960

6061

0 commit comments

Comments
 (0)