8000 Transform error messages · stdlib-js/array-bool@d095b1e · GitHub
[go: up one dir, main page]

Skip to content

Commit d095b1e

Browse files
committed
Transform error messages
1 parent 6fa8ae0 commit d095b1e

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

lib/main.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var Boolean = require( '@stdlib/boolean-ctor' );
3636
var getter = require( '@stdlib/array-base-getter' );
3737
var floor = require( '@stdlib/math-base-special-floor' );
3838
var accessorGetter = require( '@stdlib/array-base-accessor-getter' );
39-
var format = require( '@stdlib/string-format' );
39+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
4040
var fromIterator = require( './from_iterator.js' );
4141
var fromIteratorMap = require( './from_iterator_map.js' );
4242
var fromArray = require( './from_array.js' );
@@ -176,37 +176,37 @@ function BooleanArray() {
176176
buf = new Uint8Array( arg );
177177
} else if ( isObject( arg ) ) {
178178
if ( HAS_ITERATOR_SYMBOL === false ) {
179-
throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );
179+
throw new TypeError( format( 'null29', arg ) );
180180
}
181181
if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {
182-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
182+
throw new TypeError( format( 'null2A', arg ) );
183183
}
184184
buf = arg[ ITERATOR_SYMBOL ]();
185185
if ( !isFunction( buf.next ) ) {
186-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
186+
throw new TypeError( format( 'null2A', arg ) );
187187
}
188188
buf = new Uint8Array( fromIterator( buf ) );
189189
} else {
190-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
190+
throw new TypeError( format( 'null2A', arg ) );
191191
}
192192
} else {
193193
buf = arguments[ 0 ];
194194
if ( !isArrayBuffer( buf ) ) {
195-
throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );
195+
throw new TypeError( format( 'null2B', buf ) );
196196
}
197197
byteOffset = arguments[ 1 ];
198198
if ( !isNonNegativeInteger( byteOffset ) ) {
199-
throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );
199+
throw new TypeError( format( 'null2C', byteOffset ) );
200200
}
201201
if ( nargs === 2 ) {
202202
buf = new Uint8Array( buf, byteOffset );
203203
} else {
204204
len = arguments[ 2 ];
205205
if ( !isNonNegativeInteger( len ) ) {
206-
throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );
206+
throw new TypeError( format( 'null2F', len ) );
207207
}
208208
if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {
209-
throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );
209+
throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );
210210
}
211211
buf = new Uint8Array( buf, byteOffset, len );
212212
}
@@ -291,7 +291,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
291291
var len;
292292
var i;
293293
if ( !isFunction( this ) ) {
294-
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
294+
throw new TypeError( format('null01') );
295295
}
296296
if ( !isBooleanArrayConstructor( this ) ) {
297297
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
@@ -300,7 +300,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
300300
if ( nargs > 1 ) {
301301
clbk = arguments[ 1 ];
302302
if ( !isFunction( clbk ) ) {
303-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );
303+
throw new TypeError( format( 'null2H', clbk ) );
304304
}
305305
if ( nargs > 2 ) {
306306
thisArg = arguments[ 2 ];
@@ -326,7 +326,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
326326
if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len
327327
buf = src[ ITERATOR_SYMBOL ]();
328328
if ( !isFunction( buf.next ) ) {
329-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );
329+
throw new TypeError( format( 'null2J', src ) );
330330
}
331331
if ( clbk ) {
332332
tmp = fromIteratorMap( buf, clbk, thisArg );
@@ -341,7 +341,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
341341
}
342342
return out;
343343
}
344-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );
344+
throw new TypeError( format( 'null2J', src ) );
345345
});
346346

347347
/**
@@ -366,7 +366,7 @@ setReadOnly( BooleanArray, 'of', function of() {
366366
var args;
367367
var i;
368368
if ( !isFunction( this ) ) {
369-
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
369+
throw new TypeError( format('null01') );
370370
}
371371
if ( !isBooleanArrayConstructor( this ) ) {
372372
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
@@ -484,7 +484,7 @@ setReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg )
484484
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
485485
}
486486
if ( !isFunction( predicate ) ) {
487-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
487+
throw new TypeError( format( 'null3c', predicate ) );
488488
}
489489
buf = this._buffer;
490490
for ( i = 0; i < this._length; i++ ) {
@@ -530,7 +530,7 @@ setReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate,
530530
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
531531
}
532532
if ( !isFunction( predicate ) ) {
533-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
533+
throw new TypeError( format( 'null3c', predicate ) );
534534
}
535535
buf = this._buffer;
536536
for ( i = 0; i < this._length; i++ ) {
@@ -577,7 +577,7 @@ setReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, t
577577
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
578578
}
579579
if ( !isFunction( predicate ) ) {
580-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
580+
throw new TypeError( format( 'null3c', predicate ) );
581581
}
582582
buf = this._buffer;
583583
for ( i = this._length-1; i >= 0; i-- ) {
@@ -623,7 +623,7 @@ setReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( pr
623623
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
624624
}
625625
if ( !isFunction( predicate ) ) {
626-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
626+
throw new TypeError( format( 'null3c', predicate ) );
627627
}
628628
buf = this._buffer;
629629
for ( i = this._length-1; i >= 0; i-- ) {
@@ -665,7 +665,7 @@ setReadOnly( BooleanArray.prototype, 'get', function get( idx ) {
665665
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
666666
}
667667
if ( !isNonNegativeInteger( idx ) ) {
668-
throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );
668+
throw new TypeError( format( 'null2K', idx ) );
669669
}
670670
if ( idx >= this._length ) {
671671
return;
@@ -735,7 +735,7 @@ setReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {
735735
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
736736
}
737737
if ( !isFunction( fcn ) ) {
738-
throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );
738+
throw new TypeError( format('null3c'), fcn );
739739
}
740740
buf = this._buffer;
741741
out = new this.constructor( this._length );
@@ -857,15 +857,15 @@ setReadOnly( BooleanArray.prototype, 'set', function set( value ) {
857857
if ( arguments.length > 1 ) {
858858
idx = arguments[ 1 ];
859859
if ( !isNonNegativeInteger( idx ) ) {
860-
throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );
860+
throw new TypeError( format( 'null2L', idx ) );
861861
}
862862
} else {
863863
idx = 0;
864864
}
865865
if ( isCollection( value ) ) {
866866
N = value.length;
867867
if ( idx+N > this._length ) {
868-
throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );
868+
throw new RangeError( format('null03') );
869869
}
870870
if ( isBooleanArray( value ) ) {
871871
sbuf = value._buffer; // eslint-disable-line no-underscore-dangle
@@ -894,7 +894,7 @@ setReadOnly( BooleanArray.prototype, 'set', function set( value ) {
894894
return;
895895
}
896896
if ( idx >= this._length ) {
897-
throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );
897+
throw new RangeError( format( 'null2M', idx ) );
898898
}
899899
buf[ idx ] = ( value ) ? 1 : 0;
900900
});
@@ -954,7 +954,7 @@ setReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {
954954
return this;
955955
}
956956
if ( !isFunction( compareFcn ) ) {
957-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );
957+
throw new TypeError( format( 'null3c', compareFcn ) );
958958
}
959959
buf.sort( compare );
960960
return this;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@stdlib/assert-is-object": "^0.2.1",
4949
"@stdlib/boolean-ctor": "^0.2.1",
5050
"@stdlib/math-base-special-floor": "^0.2.2",
51-
"@stdlib/string-format": "^0.2.1",
51+
"@stdlib/error-tools-fmtprodmsg": "^0.2.1",
5252
"@stdlib/symbol-iterator": "^0.2.1",
5353
"@stdlib/types": "^0.3.2",
5454
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2",

0 commit comments

Comments
 (0)
0