Skip to content

Commit e90a075

Browse files
committed
feat: improve type specificity of return type and update examples
1 parent 2e68ac6 commit e90a075

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

lib/node_modules/@stdlib/ndarray/dtypes/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ var indexOf = require( '@stdlib/utils/index-of' );
109109
var dtypes = require( '@stdlib/ndarray/dtypes' );
110110

111111
var DTYPES = dtypes();
112-
var bool;
113112

114113
function isdtype( str ) {
115114
if ( indexOf( DTYPES, str ) === -1 ) {
@@ -118,7 +117,7 @@ function isdtype( str ) {
118117
return true;
119118
}
120119

121-
bool = isdtype( 'float64' );
120+
var bool = isdtype( 'float64' );
122121
// returns true
123122

124123
bool = isdtype( 'int16' );

lib/node_modules/@stdlib/ndarray/dtypes/docs/types/index.d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
// TypeScript Version: 4.1
2020

21-
/**
22-
* Data type kind.
23-
*/
24-
type Kind = 'all' | 'numeric' | 'real' | 'floating_point' | 'real_floating_point' | 'complex_floating_point' | 'integer' | 'signed_integer' | 'unsigned_integer';
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { DataType, DataTypeKind } from '@stdlib/types/ndarray';
2524

2625
/**
2726
* Returns a list of ndarray data types.
@@ -55,7 +54,7 @@ type Kind = 'all' | 'numeric' | 'real' | 'floating_point' | 'real_floating_point
5554
* var list = dtypes( 'floating_point' );
5655
* // returns [...]
5756
*/
58-
declare function dtypes( kind?: Kind ): Array<string>;
57+
declare function dtypes( kind?: DataTypeKind ): Array<DataType>;
5958

6059

6160
// EXPORTS //

lib/node_modules/@stdlib/ndarray/dtypes/docs/types/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import dtypes = require( './index' );
2121

2222
// TESTS //
2323

24-
// The function returns an array of strings...
24+
// The function returns an array of data types...
2525
{
26-
dtypes(); // $ExpectType string[]
27-
dtypes( 'floating_point' ); // $ExpectType string[]
26+
dtypes(); // $ExpectType DataType[]
27+
dtypes( 'floating_point' ); // $ExpectType DataType[]
2828
}
2929

3030
// The compiler throws an error if the function is provided an unsupported number of arguments...

lib/node_modules/@stdlib/ndarray/dtypes/examples/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var indexOf = require( '@stdlib/utils/index-of' );
2222
var dtypes = require( './../lib' );
2323

2424
var DTYPES = dtypes();
25-
var bool;
2625

2726
function isdtype( str ) {
2827
if ( indexOf( DTYPES, str ) === -1 ) {
@@ -31,7 +30,7 @@ function isdtype( str ) {
3130
return true;
3231
}
3332

34-
bool = isdtype( 'float64' );
33+
var bool = isdtype( 'float64' );
3534
console.log( bool );
3635
// => true
3736

0 commit comments

Comments
 (0)