|
20 | 20 |
|
21 | 21 | // MODULES // |
22 | 22 |
|
| 23 | +var contains = require( './../../base/assert/contains' ).factory; |
23 | 24 | var dtype = require( './../../dtype' ); |
24 | 25 | var full = require( './../../full' ); |
25 | 26 | var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
26 | 27 | var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 28 | +var dtypes = require( './../../dtypes' ); |
| 29 | +var join = require( './../../base/join' ); |
27 | 30 | var format = require( '@stdlib/string/format' ); |
28 | 31 |
|
29 | 32 |
|
30 | 33 | // VARIABLES // |
31 | 34 |
|
32 | 35 | var Z128 = new Complex128( NaN, NaN ); |
33 | 36 | var Z64 = new Complex64( NaN, NaN ); |
34 | | -var DTYPES = [ 'float64', 'float32', 'complex128', 'complex64', 'generic' ]; |
| 37 | +var DTYPES = dtypes( 'floating_point_and_generic' ); |
| 38 | +var isValidDType = contains( DTYPES ); |
35 | 39 |
|
36 | 40 |
|
37 | 41 | // MAIN // |
@@ -63,11 +67,11 @@ function nansLike( x ) { |
63 | 67 | } |
64 | 68 | if ( arguments.length > 1 ) { |
65 | 69 | dt = arguments[ 1 ]; |
66 | | - if ( DTYPES.indexOf( dt ) === -1 ) { |
67 | | - throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', DTYPES.join( '", "' ), dt ) ); |
| 70 | + if ( !isValidDType( dt ) ) { |
| 71 | + throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) ); |
68 | 72 | } |
69 | | - } else if ( DTYPES.indexOf( dt ) === -1 ) { |
70 | | - throw new TypeError( format( 'invalid argument. First argument must be one of the following data types: "%s". Value: `%s`.', DTYPES.join( '", "' ), dt ) ); |
| 73 | + } else if ( !isValidDType( dt ) ) { |
| 74 | + throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Value: `%s`.', join( DTYPES, '", "' ), dt ) ); |
71 | 75 | } |
72 | 76 | if ( dt === 'complex128' ) { |
73 | 77 | v = Z128; |
|
0 commit comments