Skip to content

Commit b9f3b77

Browse files
committed
refactor: reduce string literals
1 parent 17fa3d2 commit b9f3b77

File tree

1 file changed

+11
-12
lines changed
  • lib/node_modules/@stdlib/array/fixed-endian-factory/lib

1 file changed

+11
-12
lines changed

lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ var DTYPE2GET = {
6767
'uint32': 'getUint32',
6868
'uint16': 'getUint16'
6969
};
70-
var DTYPE2ARTICLE = {
71-
'float64': 'a',
72-
'float32': 'a',
73-
'int32': 'an',
74-
'int16': 'an',
75-
'uint32': 'a',
76-
'uint16': 'a'
70+
var CHAR2ARTICLE = {
71+
'c': 'a',
72+
'f': 'a',
73+
'i': 'an',
74+
'u': 'a',
75+
'b': 'a'
7776
};
7877
var isDataType = contains( DTYPES );
7978

@@ -367,7 +366,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
367366
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
368367
}
369368
if ( !isTypedArrayConstructor( this ) ) {
370-
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', DTYPE2ARTICLE[ dtype ], CTOR_NAME ) );
369+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
371370
}
372371
order = byteOrder( endianness );
373372
if ( order === null || !isByteOrder( order ) ) {
@@ -445,7 +444,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
445444
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
446445
}
447446
if ( !isTypedArrayConstructor( this ) ) {
448-
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', DTYPE2ARTICLE[ dtype ], CTOR_NAME ) );
447+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
449448
}
450449
order = byteOrder( endianness );
451450
if ( order === null || !isByteOrder( order ) ) {
@@ -522,7 +521,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
522521
*/
523522
setReadOnly( TypedArray.prototype, 'get', function get( idx ) {
524523
if ( !isTypedArray( this ) ) {
525-
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', DTYPE2ARTICLE[ dtype ], CTOR_NAME ) );
524+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
526525
}
527526
if ( !isNonNegativeInteger( idx ) ) {
528527
throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );
@@ -591,7 +590,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
591590
var i;
592591
var j;
593592
if ( !isTypedArray( this ) ) {
594-
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', DTYPE2ARTICLE[ dtype ], CTOR_NAME ) );
593+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
595594
}
596595
buf = this._buffer;
597596
if ( arguments.length > 1 ) {
@@ -656,7 +655,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
656655
var buf;
657656
var i;
658657
if ( !isTypedArray( this ) ) {
659-
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', DTYPE2ARTICLE[ dtype ], CTOR_NAME ) );
658+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
660659
}
661660
out = [];
662661
buf = this._buffer;

0 commit comments

Comments
 (0)