From 0af9b40459a96de181e36ad4f05c2fd73d42e49d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Apr 2026 03:32:32 +0000 Subject: [PATCH] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 665558e..4f4275f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ).factory; var lastCodeUnit = require( '@stdlib/string-base-last' ); var lastCodePoint = require( '@stdlib/string-base-last-code-point' ); var lastGraphemeCluster = require( '@stdlib/string-base-last-grapheme-cluster' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -88,7 +88,7 @@ function last( 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( 'null3F', str ) ); } opts = { 'mode': 'grapheme' @@ -102,23 +102,23 @@ function last( 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( 'null3X', 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( 'null3X', 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( 'null2V', 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( 'nullE1', 'mode', MODES.join( '", "' ), opts.mode ) ); } } } diff --git a/package.json b/package.json index 15793b8..dff4ee4 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@stdlib/string-base-last": "^0.1.2", "@stdlib/string-base-last-code-point": "^0.1.2", "@stdlib/string-base-last-grapheme-cluster": "^0.1.1", - "@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" },