diff --git a/lib/main.js b/lib/main.js index 5971a1a..27fe5b8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ).factory; var firstCodeUnit = require( '@stdlib/string-base-first' ); var firstCodePoint = require( '@stdlib/string-base-first-code-point' ); var firstGraphemeCluster = require( '@stdlib/string-base-first-grapheme-cluster' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -88,7 +88,7 @@ function first( str ) { var n; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1gp3F', str ) ); } opts = { 'mode': 'grapheme' @@ -102,23 +102,23 @@ function first( str ) { options = n; n = 1; } else if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) ); + throw new TypeError( format( '1gp3X', n ) ); } } else { // nargs > 2 n = arguments[ 1 ]; if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) ); + throw new TypeError( format( '1gp3X', n ) ); } options = arguments[ 2 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1gp2V', options ) ); } } if ( options ) { if ( hasOwnProp( options, 'mode' ) ) { opts.mode = options.mode; if ( !isMode( opts.mode ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Value: `%s`.', 'mode', MODES.join( '", "' ), opts.mode ) ); + throw new TypeError( format( '1gpE1', 'mode', MODES.join( '", "' ), opts.mode ) ); } } } diff --git a/package.json b/package.json index 8d54291..5868346 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@stdlib/string-base-first": "^0.2.3", "@stdlib/string-base-first-code-point": "^0.2.3", "@stdlib/string-base-first-grapheme-cluster": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-regexp-from-string": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" },