8000 Transform error messages · stdlib-js/utils-map-right@ab641e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab641e2

Browse files
committed
Transform error messages
1 parent 990e4f2 commit ab641e2

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/assign.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
2727
var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
2828
var broadcast = require( '@stdlib/ndarray-base-maybe-broadcast-array' );
2929
var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' );
30-
var format = require( '@stdlib/string-format' );
30+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3131
var ndarrayFcn = require( './ndarray.js' );
3232
var arrayFcn = require( './array.js' );
3333

@@ -91,14 +91,14 @@ function mapRight( arr, out, fcn, thisArg ) {
9191
var tmp;
9292
var sh;
9393
if ( !isFunction( fcn ) ) {
94-
throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) );
94+
throw new TypeError( format( '1VP3N', fcn ) );
9595
}
9696
if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
9797
if ( !isndarrayLike( out ) ) {
98-
throw new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) );
98+
throw new TypeError( format( '1VPBF', out ) );
9999
}
100100
if ( isReadOnly( out ) ) {
101-
throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' );
101+
throw new Error( format('1VP1g') );
102102
}
103103
out = ndarraylike2object( out );
104104
sh = out.shape;
@@ -112,15 +112,15 @@ function mapRight( arr, out, fcn, thisArg ) {
112112
}
113113
if ( isArrayLikeObject( arr ) ) {
114114
if ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) {
115-
throw new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) );
115+
throw new TypeError( format( '1VPBG', out ) );
116116
}
117117
if ( arr.length !== out.length ) {
118-
throw new RangeError( 'invalid arguments. Input and output arrays must have the same length.' );
118+
throw new RangeError( format('1VP1h') );
119119
}
120120
arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
121121
return out;
122122
}
123-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
123+
throw new TypeError( format( '1VPBH', arr ) );
124124
}
125125

126126

lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var zeros = require( '@stdlib/array-base-zeros' );
2727
var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
2828
var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
2929
var ndzeros = require( '@stdlib/ndarray-zeros' );
30-
var format = require( '@stdlib/string-format' );
30+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3131
var ndarrayFcn = require( './ndarray.js' );
3232
var arrayFcn = require( './array.js' );
3333

@@ -80,7 +80,7 @@ var arrayFcn = require( './array.js' );
8080
function mapRight( arr, fcn, thisArg ) {
8181
var out;
8282
if ( !isFunction( fcn ) ) {
83-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );
83+
throw new TypeError( format( '1VP2H', fcn ) );
8484
}
8585
if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
8686
arr = ndarraylike2object( arr );
@@ -96,7 +96,7 @@ function mapRight( arr, fcn, thisArg ) {
9696
arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
9797
return out;
9898
}
99-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
99+
throw new TypeError( format( '1VPBH', arr ) );
100100
}
101101

102102

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@stdlib/ndarray-base-ndarraylike2object": "^0.2.2",
4848
"@stdlib/ndarray-base-vind2bind": "^0.2.2",
4949
"@stdlib/ndarray-zeros": "^0.3.0",
50-
"@stdlib/string-format": "^0.2.2",
50+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
5151
"@stdlib/types": "^0.4.3",
5252
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
5353
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"

0 commit comments

Comments
 (0)
0