Skip to content

Commit 25248b8

Browse files
committed
Rename method
1 parent 3f0f77b commit 25248b8

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

lib/node_modules/@stdlib/strided/dtypes/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
3636
var dtypes = require( './main.js' );
3737
var enumeration = require( './enum.js' );
38-
var enumerator = require( './enumerator.js' );
38+
var str2enum = require( './str2enum.js' );
3939
var assign = require( './assign.js' );
4040

4141

4242
// MAIN //
4343

4444
setReadOnly( dtypes, 'enum', enumeration );
45-
setReadOnly( dtypes, 'enumerator', enumerator );
45+
setReadOnly( dtypes, 'str2enum', str2enum );
4646
assign( dtypes, enumeration() );
4747

4848

lib/node_modules/@stdlib/strided/dtypes/lib/enumerator.js renamed to lib/node_modules/@stdlib/strided/dtypes/lib/str2enum.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,26 @@ var dt = dtypes();
3131
// MAIN //
3232

3333
/**
34-
* Returns the integer value associated with a supported dtype for purposes of C inter-operation.
34+
* Returns the integer value associated with a supported dtype string for purposes of C inter-operation.
3535
*
3636
* ## Notes
3737
*
3838
* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the function should be used in an opaque manner.
3939
* - The main purpose of this function is JavaScript and C inter-operation of strided arrays.
4040
*
41-
* @param {string} dtype - data type
41+
* @param {string} dtype - data type string
4242
* @returns {(integer|void)} integer value or undefined
4343
*
4444
* @example
45-
* var v = enumerator( 'int8' );
45+
* var v = str2enum( 'int8' );
4646
* // returns <number>
4747
*/
48-
function enumerator( dtype ) {
49-
return dt[ dtype ];
48+
function str2enum( dtype ) {
49+
var v = dt[ dtype ];
50+
return ( typeof v === 'number' ) ? v : void 0; // note: we include this guard to prevent walking the prototype chain
5051
}
5152

5253

5354
// EXPORTS //
5455

55-
module.exports = enumerator;
56+
module.exports = str2enum;

lib/node_modules/@stdlib/strided/dtypes/test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ tape( 'attached to the main function is an `enum` method to return an object map
9898
t.end();
9999
});
100100

101-
tape( 'attached to the main function is an `enumerator` method to the integer value associated with a provided dtype for C inter-operation', function test( t ) {
101+
tape( 'attached to the main function is a `str2enum` method to retrieve the integer value associated with a provided dtype string for C inter-operation', function test( t ) {
102102
var i;
103103

104-
t.strictEqual( hasOwnProp( dtypes, 'enumerator' ), true, 'has property' );
105-
t.strictEqual( typeof dtypes.enumerator, 'function', 'has method' );
104+
t.strictEqual( hasOwnProp( dtypes, 'str2enum' ), true, 'has property' );
105+
t.strictEqual( typeof dtypes.str2enum, 'function', 'has method' );
106106

107107
for ( i = 0; i < DTYPES.length; i++ ) {
108-
t.strictEqual( isNonNegativeInteger( dtypes.enumerator( DTYPES[i] ) ), true, 'returns expected value' );
108+
t.strictEqual( isNonNegativeInteger( dtypes.str2enum( DTYPES[i] ) ), true, 'returns expected value' );
109109
}
110110
t.end();
111111
});

0 commit comments

Comments
 (0)