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

Skip to content

Commit d9b4ccb

Browse files
committed
Transform error messages
1 parent fde7dc3 commit d9b4ccb

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

lib/main.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var Uint8Array = require( '@stdlib/array-uint8' );
3535
var Boolean = require( '@stdlib/boolean-ctor' );
3636
var getter = require( '@stdlib/array-base-getter' );
3737
var accessorGetter = require( '@stdlib/array-base-accessor-getter' );
38-
var format = require( '@stdlib/string-format' );
38+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3939
var fromIterator = require( './from_iterator.js' );
4040
var fromIteratorMap = require( './from_iterator_map.js' );
4141
var fromArray = require( './from_array.js' );
@@ -175,37 +175,37 @@ function BooleanArray() {
175175
buf = new Uint8Array( arg );
176176
} else if ( isObject( arg ) ) {
177177
if ( HAS_ITERATOR_SYMBOL === false ) {
178-
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 ) );
178+
throw new TypeError( format( 'null29', arg ) );
179179
}
180180
if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {
181-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
181+
throw new TypeError( format( 'null2A', arg ) );
182182
}
183183
buf = arg[ ITERATOR_SYMBOL ]();
184184
if ( !isFunction( buf.next ) ) {
185-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
185+
throw new TypeError( format( 'null2A', arg ) );
186186
}
187187
buf = new Uint8Array( fromIterator( buf ) );
188188
} else {
189-
throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
189+
throw new TypeError( format( 'null2A', arg ) );
190190
}
191191
} else {
192192
buf = arguments[ 0 ];
193193
if ( !isArrayBuffer( buf ) ) {
194-
throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );
194+
throw new TypeError( format( 'null2B', buf ) );
195195
}
196196
byteOffset = arguments[ 1 ];
197197
if ( !isNonNegativeInteger( byteOffset ) ) {
198-
throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );
198+
throw new TypeError( format( 'null2C', byteOffset ) );
199199
}
200200
if ( nargs === 2 ) {
201201
buf = new Uint8Array( buf, byteOffset );
202202
} else {
203203
len = arguments[ 2 ];
204204
if ( !isNonNegativeInteger( len ) ) {
205-
throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );
205+
throw new TypeError( format( 'null2F', len ) );
206206
}
207207
if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {
208-
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 ) );
208+
throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );
209209
}
210210
buf = new Uint8Array( buf, byteOffset, len );
211211
}
@@ -290,7 +290,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
290290
var len;
291291
var i;
292292
if ( !isFunction( this ) ) {
293-
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
293+
throw new TypeError( format('null01') );
294294
}
295295
if ( !isBooleanArrayConstructor( this ) ) {
296296
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
@@ -299,7 +299,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
299299
if ( nargs > 1 ) {
300300
clbk = arguments[ 1 ];
301301
if ( !isFunction( clbk ) ) {
302-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );
302+
throw new TypeError( format( 'null2H', clbk ) );
303303
}
304304
if ( nargs > 2 ) {
305305
thisArg = arguments[ 2 ];
@@ -325,7 +325,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
325325
if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len
326326
buf = src[ ITERATOR_SYMBOL ]();
327327
if ( !isFunction( buf.next ) ) {
328-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );
328+
throw new TypeError( format( 'null2J', src ) );
329329
}
330330
if ( clbk ) {
331331
tmp = fromIteratorMap( buf, clbk, thisArg );
@@ -340,7 +340,7 @@ setReadOnly( BooleanArray, 'from', function from( src ) {
340340
}
341341
return out;
342342
}
343-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );
343+
throw new TypeError( format( 'null2J', src ) );
344344
});
345345

346346
/**
@@ -365,7 +365,7 @@ setReadOnly( BooleanArray, 'of', function of() {
365365
var args;
366366
var i;
367367
if ( !isFunction( this ) ) {
368-
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
368+
throw new TypeError( format('null01') );
369369
}
370370
if ( !isBooleanArrayConstructor( this ) ) {
371371
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
@@ -483,7 +483,7 @@ setReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg )
483483
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
484484
}
485485
if ( !isFunction( predicate ) ) {
486-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
486+
throw new TypeError( format( 'null3c', predicate ) );
487487
}
488488
buf = this._buffer;
489489
for ( i = 0; i < this._length; i++ ) {
529529
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
530530
}
531531
if ( !isFunction( predicate ) ) {
532-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );
532+
throw new TypeError( format( 'null3c', predicate ) );
533533
}
534534
buf = this._buffer;
535535
for ( i = this._length-1; i >= 0; i-- ) {
@@ -570,7 +570,7 @@ setReadOnly( BooleanArray.prototype, 'get', function get( idx ) {
570570
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
571571
}
572572
if ( !isNonNegativeInteger( idx ) ) {
573-
throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );
573+
throw new TypeError( format( 'null2K', idx ) );
574574
}
575575
if ( idx >= this._length ) {
576576
return;
@@ -640,7 +640,7 @@ setReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {
640640
throw new TypeError( 'invalid invocation. `this` is not a boolean array.' );
641641
}
642642
if ( !isFunction( fcn ) ) {
643-
throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );
643+
throw new TypeError( format('null3c'), fcn );
644644
}
645645
buf = this._buffer;
646646
out = new this.constructor( this._length );
@@ -711,15 +711,15 @@ setReadOnly( BooleanArray.prototype, 'set', function set( value ) {
711711
if ( arguments.length > 1 ) {
712712
idx = arguments[ 1 ];
713713
if ( !isNonNegativeInteger( idx ) ) {
714-
throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );
714+
throw new TypeError( format( 'null2L', idx ) );
715715
}
716716
} else {
717717
idx = 0;
718718
}
719719
if ( isCollection( value ) ) {
720720 10000
N = value.length;
721721
if ( idx+N > this._length ) {
722-
throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );
722+
throw new RangeError( format('null03') );
723723
}
724724
if ( isBooleanArray( value ) ) {
725725
sbuf = value._buffer; // eslint-disable-line no-underscore-dangle
@@ -748,7 +748,7 @@ setReadOnly( BooleanArray.prototype, 'set', function set( value ) {
748748
return;
749749
}
750750
if ( idx >= this._length ) {
751-
throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );
751+
throw new RangeError( format( 'null2M', idx ) );
752752
}
753753
buf[ idx ] = ( value ) ? 1 : 0;
754754
});
@@ -808,7 +808,7 @@ setReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {
808808
return this;
809809
}
810810
if ( !isFunction( compareFcn ) ) {
811-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );
811+
throw new TypeError( format( 'null3c', compareFcn ) );
812812
}
813813
buf.sort( compare );
814814
return this;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@stdlib/assert-is-nonnegative-integer": "^0.2.1",
4848
"@stdlib/assert-is-object": "^0.2.1",
4949
"@stdlib/boolean-ctor": "^0.2.1",
50-
"@stdlib/string-format": "^0.2.1",
50+
"@stdlib/error-tools-fmtprodmsg": "^0.2.1",
5151
"@stdlib/symbol-iterator": "^0.2.1",
5252
"@stdlib/types": "^0.3.2",
5353
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2",

0 commit comments

Comments
 (0)
0