Skip to content

Commit d88c946

Browse files
committed
refactor: reduce dtype string duplication
1 parent 894eb44 commit d88c946

9 files changed

Lines changed: 12 additions & 30 deletions

File tree

lib/node_modules/@stdlib/array/typed-complex-dtypes/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,9 @@ Returns a list of complex typed array data types.
4646

4747
```javascript
4848
var out = dtypes();
49-
// returns [ 'complex64', 'complex128' ]
49+
// e.g., returns [ 'complex64', ... ]
5050
```
5151

52-
The output `array` contains the following data types:
53-
54-
- `complex64`: single-precision floating-point complex numbers.
55-
- `complex128`: double-precision floating-point complex numbers.
56-
5752
</section>
5853

5954
<!-- /.usage -->
@@ -79,7 +74,6 @@ var indexOf = require( '@stdlib/utils/index-of' );
7974
var dtypes = require( '@stdlib/array/typed-complex-dtypes' );
8075

8176
var DTYPES = dtypes();
82-
var bool;
8377

8478
function isdtype( str ) {
8579
if ( indexOf( DTYPES, str ) === -1 ) {
@@ -88,7 +82,7 @@ function isdtype( str ) {
8882
return true;
8983
}
9084

91-
bool = isdtype( 'complex64' );
85+
var bool = isdtype( 'complex64' );
9286
// returns true
9387

9488
bool = isdtype( 'complex128' );

lib/node_modules/@stdlib/array/typed-complex-dtypes/benchmark/benchmark.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ bench( pkg, function benchmark( b ) {
3535
b.tic();
3636
for ( i = 0; i < b.iterations; i++ ) {
3737
out = dtypes();
38-
if ( out.length !== 2 ) {
39-
b.fail( 'should return an array of length 2' );
38+
if ( out.length < 2 ) {
39+
b.fail( 'should return an array' );
4040
}
4141
}
4242
b.toc();

lib/node_modules/@stdlib/array/typed-complex-dtypes/docs/repl.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
{{alias}}()
33
Returns a list of complex typed array data types.
44

5-
The output array contains the following data types:
6-
7-
- complex64: single-precision floating-point complex numbers.
8-
- complex128: double-precision floating-point complex numbers.
9-
105
Returns
116
-------
127
out: Array<string>

lib/node_modules/@stdlib/array/typed-complex-dtypes/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ComplexFloatingPointDataType as DataType } from '@stdlib/types/array';
2929
*
3030
* @example
3131
* var list = dtypes();
32-
* // returns [ 'complex64', 'complex128' ]
32+
* // e.g., returns [ 'complex64', ... ]
3333
*/
3434
declare function dtypes(): Array<DataType>;
3535

lib/node_modules/@stdlib/array/typed-complex-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( 'complex64' );
33+
var bool = isdtype( 'complex64' );
3534
console.log( bool );
3635
// => true
3736

lib/node_modules/@stdlib/array/typed-complex-dtypes/lib/dtypes.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/node_modules/@stdlib/array/typed-complex-dtypes/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* var dtypes = require( '@stdlib/array/typed-complex-dtypes' );
2828
*
2929
* var list = dtypes();
30-
* // returns [ 'complex64', 'complex128' ]
30+
* // e.g., returns [ 'complex64', ... ]
3131
*/
3232

3333
// MODULES //

lib/node_modules/@stdlib/array/typed-complex-dtypes/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var DTYPES = require( './dtypes.json' );
23+
var dt = require( '@stdlib/array/dtypes' );
2424

2525

2626
// MAIN //
@@ -32,10 +32,10 @@ var DTYPES = require( './dtypes.json' );
3232
*
3333
* @example
3434
* var list = dtypes();
35-
* // returns [ 'complex64', 'complex128' ]
35+
* // e.g., returns [ 'complex64', ... ]
3636
*/
3737
function dtypes() {
38-
return DTYPES.slice();
38+
return dt( 'complex_floating_point' );
3939
}
4040

4141

lib/node_modules/@stdlib/array/typed-complex-dtypes/test/test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var dt = require( '@stdlib/array/dtypes' );
2425
var dtypes = require( './../lib' );
2526

2627

@@ -36,10 +37,7 @@ tape( 'the function returns a list of complex typed array data types', function
3637
var expected;
3738
var actual;
3839

39-
expected = [
40-
'complex64',
41-
'complex128'
42-
];
40+
expected = dt( 'complex_floating_point' );
4341
actual = dtypes();
4442

4543
t.deepEqual( actual, expected, 'returns expected value' );

0 commit comments

Comments
 (0)