@stdlib/string-replace
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -27,2 +27,3 @@ /** | ||
var isRegExp = require( '@stdlib/assert-is-regexp' ); | ||
var format = require( '@stdlib/string-format' ); | ||
@@ -38,5 +39,5 @@ | ||
* @param {(string|Function)} newval - replacement value or function | ||
* @throws {TypeError} first argument must be a string primitive | ||
* @throws {TypeError} second argument argument must be a string primitive or regular expression | ||
* @throws {TypeError} third argument must be a string primitive or function | ||
* @throws {TypeError} first argument must be a string | ||
* @throws {TypeError} second argument argument must be a string or regular expression | ||
* @throws {TypeError} third argument must be a string or function | ||
* @returns {string} new string containing replacement(s) | ||
@@ -68,3 +69,3 @@ * | ||
if ( !isString( str ) ) { | ||
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + str + '`.' ); | ||
throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); | ||
} | ||
@@ -76,6 +77,6 @@ if ( isString( search ) ) { | ||
else if ( !isRegExp( search ) ) { | ||
throw new TypeError( 'invalid argument. Second argument must be a string primitive or regular expression. Value: `' + search + '`.' ); | ||
throw new TypeError( format( 'invalid argument. Second argument must be a string or regular expression. Value: `%s`.', search ) ); | ||
} | ||
if ( !isString( newval ) && !isFunction( newval ) ) { | ||
throw new TypeError( 'invalid argument. Third argument must be a string primitive or replacement function. Value: `' + newval + '`.' ); | ||
throw new TypeError( format( 'invalid argument. Third argument must be a string or replacement function. Value: `%s`.', newval ) ); | ||
} | ||
@@ -82,0 +83,0 @@ return str.replace( search, newval ); |
{ | ||
"name": "@stdlib/string-replace", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Replace search occurrences with a replacement string.", | ||
@@ -52,2 +52,3 @@ "license": "Apache-2.0", | ||
"@stdlib/streams-node-stdin": "^0.0.x", | ||
"@stdlib/string-format": "^0.0.x", | ||
"@stdlib/utils-escape-regexp-string": "^0.0.x", | ||
@@ -54,0 +55,0 @@ "@stdlib/utils-regexp-from-string": "^0.0.x" |
@@ -226,4 +226,4 @@ <!-- | ||
[test-image]: https://github.com/stdlib-js/string-replace/actions/workflows/test.yml/badge.svg | ||
[test-url]: https://github.com/stdlib-js/string-replace/actions/workflows/test.yml | ||
[test-image]: https://github.com/stdlib-js/string-replace/actions/workflows/test.yml/badge.svg?branch=v0.0.11 | ||
[test-url]: https://github.com/stdlib-js/string-replace/actions/workflows/test.yml?query=branch:v0.0.11 | ||
@@ -240,2 +240,9 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-replace/main.svg | ||
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
[chat-url]: https://gitter.im/stdlib-js/stdlib/ | ||
[stdlib]: https://github.com/stdlib-js/stdlib | ||
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors | ||
[umd]: https://github.com/umdjs/umd | ||
@@ -247,10 +254,4 @@ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules | ||
[esm-url]: https://github.com/stdlib-js/string-replace/tree/esm | ||
[branches-url]: https://github.com/stdlib-js/string-replace/blob/main/branches.md | ||
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
[chat-url]: https://gitter.im/stdlib-js/stdlib/ | ||
[stdlib]: https://github.com/stdlib-js/stdlib | ||
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors | ||
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string-replace/main/LICENSE | ||
@@ -257,0 +258,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
1
243
265
30705
12
1
+ Added@stdlib/string-format@^0.0.x