Skip to content

Commit dcad548

Browse files
committed
Transform error messages
1 parent 0dc8602 commit dcad548

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/factory.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var isFunction = require( '@stdlib/assert-is-function' );
2424
var isCollection = require( '@stdlib/assert-is-collection' );
2525
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
26-
var format = require( '@stdlib/string-format' );
26+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2727
var PINF = require( '@stdlib/constants-float64-pinf' );
2828
var validate = require( './validate.js' );
2929
var limit = require( './limit.js' );
@@ -110,7 +110,7 @@ function factory( options, predicate ) {
110110
f = options;
111111
}
112112
if ( !isFunction( f ) ) {
113-
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
113+
throw new TypeError( format( '1Rh3q', f ) );
114114
}
115115
if ( opts.series ) {
116116
opts.limit = 1;
@@ -133,13 +133,13 @@ function factory( options, predicate ) {
133133
*/
134134
function someByAsync( collection, n, done ) {
135135
if ( !isCollection( collection ) ) {
136-
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
136+
throw new TypeError( format( '1RhAh', collection ) );
137137
}
138138
if ( !isPositiveInteger( n ) ) {
139-
throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) );
139+
throw new TypeError( format( '1Rh45', n ) );
140140
}
141141
if ( !isFunction( done ) ) {
142-
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
142+
throw new TypeError( format( '1Rh3q', done ) );
143143
}
144144
return limit( collection, n, opts, f, clbk );
145145

lib/validate.js

Lines changed: 4 additions & 4 deletions
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( '1Rh2V', 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( '1Rh2o', '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( '1Rh3P', 'limit', opts.limit ) );
7272
}
7373
}
7474
return null;

package.json

Lines changed: 1 addition & 1 deletion
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)