Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 057ad01

Browse files
committed
Transform error messages
1 parent e0b0e42 commit 057ad01

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/factory.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var isFunction = require( '@stdlib/assert-is-function' );
2424
var isCollection = require( '@stdlib/assert-is-collection' );
25-
var format = require( '@stdlib/string-format' );
25+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2626
var PINF = require( '@stdlib/constants-float64-pinf' );
2727
var validate = require( './validate.js' );
2828
var limit = require( './limit.js' );
@@ -109,7 +109,7 @@ function factory( options, fcn ) {
109109
f = options;
110110
}
111111
if ( !isFunction( f ) ) {
112-
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
112+
throw new TypeError( format( '1Rb3q', f ) );
113113
}
114114
if ( opts.series === void 0 && opts.limit === void 0 ) {
115115
opts.series = true;
@@ -134,10 +134,10 @@ function factory( options, fcn ) {
134134
*/
135135
function reduceAsync( collection, initial, done ) {
136136
if ( !isCollection( collection ) ) {
137-
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
137+
throw new TypeError( format( '1RbAh', collection ) );
138138
}
139139
if ( !isFunction( done ) ) {
140-
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
140+
throw new TypeError( format( '1Rb3q', done ) );
141141
}
142142
return limit( collection, initial, opts, f, clbk );
143143

lib/validate.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
2525
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
2626
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828

2929

3030
// MAIN //
@@ -54,21 +54,21 @@ var format = require( '@stdlib/string-format' );
5454
*/
5555
function validate( opts, options ) {
5656
if ( !isObject( options ) ) {
57-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
57+
return new TypeError( format( '1Rb2V', options ) );
5858
}
5959
if ( hasOwnProp( options, 'thisArg' ) ) {
6060
opts.thisArg = options.thisArg;
6161
}
6262
if ( hasOwnProp( options, 'series' ) ) {
6363
opts.series = options.series;
6464
if ( !isBoolean( opts.series ) ) {
65-
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );
65+
return new TypeError( format( '1Rb2o', 'series', opts.series ) );
6666
}
6767
}
6868
if ( hasOwnProp( options, 'limit' ) ) {
6969
opts.limit = options.limit;
7070
if ( !isPositiveInteger( opts.limit ) ) {
71-
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );
71+
return new TypeError( format( '1Rb3P', 'limit', opts.limit ) );
7272
}
7373
}
7474
return null;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@stdlib/assert-is-plain-object": "^0.2.2",
4545
"@stdlib/assert-is-positive-integer": "^0.2.2",
4646
"@stdlib/constants-float64-pinf": "^0.2.2",
47-
"@stdlib/string-format": "^0.2.2",
47+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
4848
"@stdlib/types": "^0.4.1",
4949
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
5050
"debug": "^2.6.9",

0 commit comments

Comments
 (0)