Skip to content

Commit 876bdc5

Browse files
committed
Move functions to separate packages
1 parent 3deb612 commit 876bdc5

File tree

10 files changed

+44
-391
lines changed

10 files changed

+44
-391
lines changed

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

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,52 @@ var dt = ndtypes();
3131
// MAIN //
3232

3333
/**
34-
* Object mapping supported dtypes to integer values for purposes of C inter-operation.
34+
* Returns an object mapping supported data strings to enumeration constants for purposes of C inter-operation.
3535
*
3636
* ## Notes
3737
*
38-
* - The object should match the C `dtypes.h` enumeration!!!!
38+
* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner.
39+
* - The main purpose of this function is JavaScript and C inter-operation of strided arrays.
3940
*
4041
* @private
41-
* @name ENUM
42-
* @constant
43-
* @type {Object}
42+
* @returns {Object} object mapping supported data strings strings to enumeration constants
43+
*
44+
* @example
45+
* var table = enumeration();
46+
* // returns <Object>
4447
*/
45-
var ENUM = {
46-
'bool': dt[ 'bool' ],
48+
function enumeration() {
49+
// NOTE: the returned object should match the C `dtypes.h` enumeration!!!!
50+
return {
51+
'bool': dt[ 'bool' ],
4752

48-
'int8': dt[ 'int8' ],
49-
'uint8': dt[ 'uint8' ],
50-
'uint8c': dt[ 'uint8c' ],
51-
'int16': dt[ 'int16' ],
52-
'uint16': dt[ 'uint16' ],
53-
'int32': dt[ 'int32' ],
54-
'uint32': dt[ 'uint32' ],
55-
'int64': dt[ 'int64' ],
56-
'uint64': dt[ 'uint64' ],
53+
'int8': dt[ 'int8' ],
54+
'uint8': dt[ 'uint8' ],
55+
'uint8c': dt[ 'uint8c' ],
56+
'int16': dt[ 'int16' ],
57+
'uint16': dt[ 'uint16' ],
58+
'int32': dt[ 'int32' ],
59+
'uint32': dt[ 'uint32' ],
60+
'int64': dt[ 'int64' ],
61+
'uint64': dt[ 'uint64' ],
5762

58-
'float32': dt[ 'float32' ],
59-
'float64': dt[ 'float64' ],
63+
'float32': dt[ 'float32' ],
64+
'float64': dt[ 'float64' ],
6065

61-
'complex64': dt[ 'complex64' ],
62-
'complex128': dt[ 'complex128' ],
66+
'complex64': dt[ 'complex64' ],
67+
'complex128': dt[ 'complex128' ],
6368

64-
'binary': dt[ 'binary' ],
69+
'binary': dt[ 'binary' ],
6570

66-
'generic': dt[ 'generic' ],
71+
'generic': dt[ 'generic' ],
6772

68-
'notype': dt[ 'notype' ],
73+
'notype': dt[ 'notype' ],
6974

70-
'userdefined_type': dt[ 'userdefined_type' ]
71-
};
75+
'userdefined_type': dt[ 'userdefined_type' ]
76+
};
77+
}
7278

7379

7480
// EXPORTS //
7581

76-
module.exports = ENUM;
82+
module.exports = enumeration;

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

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

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

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

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

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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@
2828
*
2929
* var list = dtypes();
3030
* // returns [...]
31+
*
32+
* @example
33+
* var enumeration = require( '@stdlib/strided/dtypes' ).enum;
34+
*
35+
* var table = enumeration();
36+
* // returns {...}
3137
*/
3238

3339
// MODULES //
3440

3541
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
3642
var dtypes = require( './main.js' );
37-
var enumeration = require( './enumeration.js' );
38-
var str2enum = require( './str2enum.js' );
39-
var enum2str = require( './enum2str.js' );
40-
var resolve = require( './resolve_enum.js' );
43+
var enumeration = require( './enum.js' );
4144
var assign = require( './assign.js' );
4245

4346

4447
// MAIN //
4548

4649
setReadOnly( dtypes, 'enum', enumeration );
47-
setReadOnly( dtypes, 'str2enum', str2enum );
48-
setReadOnly( dtypes, 'enum2str', enum2str );
49-
setReadOnly( dtypes, 'resolve', resolve );
5050
assign( dtypes, enumeration() );
5151

5252

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ var DTYPES = require( './dtypes.json' );
2626
// MAIN //
2727

2828
/**
29-
* Returns a list of strided array data types.
29+
* Returns a list of strided array data type strings.
3030
*
31-
* @returns {StringArray} list of strided array data types
31+
* @returns {StringArray} list of strided array data type strings
3232
*
3333
* @example
3434
* var list = dtypes();

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

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

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

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

0 commit comments

Comments
 (0)