Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stdlib/string-replace

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/string-replace - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

13

lib/replace.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc