8000 Transform error messages · stdlib-js/string-replace@5ab9a07 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 5ab9a07

Browse files
committed
Transform error messages
1 parent 5d017bd commit 5ab9a07

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var rescape = require( '@stdlib/utils-escape-regexp-string' );
2424
var isFunction = require( '@stdlib/assert-is-function' );
2525
var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
2626
var isRegExp = require( '@stdlib/assert-is-regexp' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828
var base = require( '@stdlib/string-base-replace' );
2929

3030

@@ -65,15 +65,15 @@ var base = require( '@stdlib/string-base-replace' );
6565
*/
6666
function replace( str, search, newval ) {
6767
if ( !isString( str ) ) {
68-
throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
68+
throw new TypeError( format( '1PJ3F', str ) );
6969
}
7070
if ( isString( search ) ) {
7171
search = new RegExp( rescape( search ), 'g' );
7272
} else if ( !isRegExp( search ) ) {
73-
throw new TypeError( format( 'invalid argument. Second argument must be a string or regular expression. Value: `%s`.', search ) );
73+
throw new TypeError( format( '1PJAT', search ) );
7474
}
7575
if ( !isString( newval ) && !isFunction( newval ) ) {
76-
throw new TypeError( format( 'invalid argument. Third argument must be a string or replacement function. Value: `%s`.', newval ) );
76+
throw new TypeError( format( '1PJAU', newval ) );
7777
}
7878
return base( str, search, newval );
7979
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@stdlib/regexp-eol": "^0.2.2",
5151
"@stdlib/streams-node-stdin": "^0.2.2",
5252
"@stdlib/string-base-replace": "^0.2.2",
53-
"@stdlib/string-format": "^0.2.2",
53+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
5454
"@stdlib/utils-escape-regexp-string": "^0.2.2",
5555
"@stdlib/utils-regexp-from-string": "^0.2.2",
5656
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"

0 commit comments

Comments
 (0)
0