Skip to content

Commit 47388ca

Browse files
committed
Transform error messages
1 parent ac97088 commit 47388ca

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
2424
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
25-
var format = require( '@stdlib/string-format' );
25+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2626
var floor = require( '@stdlib/math-base-special-floor' );
2727
var validate = require( './validate.js' );
2828

@@ -88,7 +88,7 @@ function iterPulse( options ) {
8888
opts.duration = floor( opts.period/2 );
8989
}
9090
if ( opts.duration >= opts.period ) {
91-
throw new RangeError( format( 'invalid option. `%s` option must be less than the period. Option: `%s`.', 'duration', opts.duration ) );
91+
throw new RangeError( format( '0tT8O', 'duration', opts.duration ) );
9292
}
9393
t = ( opts.period-opts.offset ) % opts.period;
9494
if ( t < 0 ) {

lib/validate.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2727
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
2828
var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
2929
var isnan = require( '@stdlib/math-base-assert-is-nan' );
30-
var format = require( '@stdlib/string-format' );
30+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3131

3232

3333
// MAIN //
@@ -58,42 +58,42 @@ var format = require( '@stdlib/string-format' );
5858
*/
5959
function validate( opts, options ) {
6060
if ( !isPlainObject( options ) ) {
61-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
61+
return new TypeError( format( '0tT2V', options ) );
6262
}
6363
if ( hasOwnProp( options, 'duration' ) ) {
6464
opts.duration = options.duration;
6565
if ( !isPositiveInteger( options.duration ) ) {
66-
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'duration', options.duration ) );
66+
return new TypeError( format( '0tT3P', 'duration', options.duration ) );
6767
}
6868
}
6969
if ( hasOwnProp( options, 'period' ) ) {
7070
opts.period = options.period;
7171
if ( !isPositiveInteger( options.period ) ) {
72-
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'period', options.period ) );
72+
return new TypeError( format( '0tT3P', 'period', options.period ) );
7373
}
7474
}
7575
if ( hasOwnProp( options, 'min' ) ) {
7676
opts.min = options.min;
7777
if ( !isNumber( options.min ) || isnan( options.min ) ) {
78-
return new TypeError( format( 'invalid option. `%s` option must be a number. Option: `%s`.', 'min', options.min ) );
78+
return new TypeError( format( '0tT8P', 'min', options.min ) );
7979
}
8080
}
8181
if ( hasOwnProp( options, 'max' ) ) {
8282
opts.max = options.max;
8383
if ( !isNumber( options.max ) || isnan( options.max ) ) {
84-
return new TypeError( format( 'invalid option. `%s` option must be a number. Option: `%s`.', 'max', options.max ) );
84+
return new TypeError( format( '0tT8P', 'max', options.max ) );
8585
}
8686
}
8787
if ( hasOwnProp( options, 'offset' ) ) {
8888
opts.offset = options.offset;
8989
if ( !isInteger( options.offset ) ) {
90-
return new TypeError( format( 'invalid option. `%s` option must be an integer. Option: `%s`.', 'offset', options.offset ) );
90+
return new TypeError( format( '0tT8M', 'offset', options.offset ) );
9191
}
9292
}
9393
if ( hasOwnProp( options, 'iter' ) ) {
9494
opts.iter = options.iter;
9595
if ( !isNonNegativeInteger( options.iter ) ) {
96-
return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );
96+
return new TypeError( format( '0tT2t', 'iter', options.iter ) );
9797
}
9898
}
9999
return null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@stdlib/assert-is-positive-integer": "^0.2.2",
4646
"@stdlib/math-base-assert-is-nan": "^0.2.2",
4747
"@stdlib/math-base-special-floor": "^0.2.3",
48-
"@stdlib/string-format": "^0.2.2",
48+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
4949
"@stdlib/symbol-iterator": "^0.2.2",
5050
"@stdlib/types": "^0.4.3",
5151
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",

0 commit comments

Comments
 (0)