Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stdlib/string-base-replace-after

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/string-base-replace-after - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+1
-1
dist/index.js.map
{
"version": 3,
"sources": ["../lib/main.js", "../lib/index.js"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Replaces the substring after the first occurrence of a specified search string.\n*\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {string} replacement - replacement string\n* @param {integer} fromIndex - index at which to start the search\n* @returns {string} - string\n*\n* @example\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 0 );\n* // returns 'beep foo'\n*\n* @example\n* var out = replaceAfter( 'beep boop', 'p', 'foo', 5 );\n* // returns 'beep boopfoo'\n*\n* @example\n* var out = replaceAfter( 'Hello World!', '', 'foo', 0 );\n* // returns 'Hello World!'\n*\n* @example\n* var out = replaceAfter( 'Hello World!', 'xyz', 'foo', 0 );\n* // returns 'Hello World!'\n*\n* @example\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 5 );\n* // returns 'beep boop'\n*\n* @example\n* var out = replaceAfter( 'beep boop beep baz', 'beep', 'foo', 5 );\n* // returns 'beep boop beepfoo'\n*/\nfunction replaceAfter( str, search, replacement, fromIndex ) {\n\tvar idx;\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += str.length;\n\t} else if ( fromIndex >= str.length ) {\n\t\treturn str;\n\t}\n\tidx = str.indexOf( search, fromIndex );\n\tif ( str === '' || search === '' || replacement === '' || idx < 0 ) {\n\t\treturn str;\n\t}\n\treturn str.substring( 0, idx + search.length ) + replacement;\n}\n\n\n// EXPORTS //\n\nmodule.exports = replaceAfter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Replace the substring after the first occurrence of a specified search string.\n*\n* @module @stdlib/string-base-replace-after\n*\n* @example\n* var replaceAfter = require( '@stdlib/string-base-replace-after' );\n*\n* var str = 'beep boop';\n*\n* var out = replaceAfter( str, ' ', 'foo', 0 );\n* // returns 'beep foo'\n*\n* out = replaceAfter( str, 'o', 'bar', 0 );\n* // returns 'beep bobar'\n*\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 5 );\n* // returns 'beep foo'\n*\n* var out = replaceAfter( 'beep boop beep baz', 'beep', 'foo', 5 );\n* // returns 'beep boop beepfoo'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Replaces the substring after the first occurrence of a specified search string.\n*\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {string} replacement - replacement string\n* @param {integer} fromIndex - index at which to start the search\n* @returns {string} output string\n*\n* @example\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 0 );\n* // returns 'beep foo'\n*\n* @example\n* var out = replaceAfter( 'beep boop', 'p', 'foo', 5 );\n* // returns 'beep boopfoo'\n*\n* @example\n* var out = replaceAfter( 'Hello World!', '', 'foo', 0 );\n* // returns 'Hello World!'\n*\n* @example\n* var out = replaceAfter( 'Hello World!', 'xyz', 'foo', 0 );\n* // returns 'Hello World!'\n*\n* @example\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 5 );\n* // returns 'beep boop'\n*\n* @example\n* var out = replaceAfter( 'beep boop beep baz', 'beep', 'foo', 5 );\n* // returns 'beep boop beepfoo'\n*/\nfunction replaceAfter( str, search, replacement, fromIndex ) {\n\tvar idx;\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += str.length;\n\t} else if ( fromIndex >= str.length ) {\n\t\treturn str;\n\t}\n\tidx = str.indexOf( search, fromIndex );\n\tif ( str === '' || search === '' || replacement === '' || idx < 0 ) {\n\t\treturn str;\n\t}\n\treturn str.substring( 0, idx + search.length ) + replacement;\n}\n\n\n// EXPORTS //\n\nmodule.exports = replaceAfter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Replace the substring after the first occurrence of a specified search string.\n*\n* @module @stdlib/string-base-replace-after\n*\n* @example\n* var replaceAfter = require( '@stdlib/string-base-replace-after' );\n*\n* var str = 'beep boop';\n*\n* var out = replaceAfter( str, ' ', 'foo', 0 );\n* // returns 'beep foo'\n*\n* out = replaceAfter( str, 'o', 'bar', 0 );\n* // returns 'beep bobar'\n*\n* var out = replaceAfter( 'beep boop', ' ', 'foo', 5 );\n* // returns 'beep boop'\n*\n* var out = replaceAfter( 'beep boop beep baz', 'beep', 'foo', 5 );\n* // returns 'beep boop beepfoo'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAcC,EAAKC,EAAQC,EAAaC,EAAY,CAC5D,IAAIC,EACJ,GAAKD,EAAY,EAChBA,GAAaH,EAAI,eACNG,GAAaH,EAAI,OAC5B,OAAOA,EAGR,OADAI,EAAMJ,EAAI,QAASC,EAAQE,CAAU,EAChCH,IAAQ,IAAMC,IAAW,IAAMC,IAAgB,IAAME,EAAM,EACxDJ,EAEDA,EAAI,UAAW,EAAGI,EAAMH,EAAO,MAAO,EAAIC,CAClD,CAKAJ,EAAO,QAAUC,IC3BjB,IAAIM,EAAO,IAKX,OAAO,QAAUA",
"names": ["require_main", "__commonJSMin", "exports", "module", "replaceAfter", "str", "search", "replacement", "fromIndex", "idx", "main"]
}

@@ -53,3 +53,3 @@ /*

* var out = replaceAfter( 'beep boop', ' ', 'foo' , 5 );
* // returns 'beep foo'
* // returns 'beep boop'
*

@@ -56,0 +56,0 @@ * @example

@@ -38,3 +38,3 @@ /**

* var out = replaceAfter( 'beep boop', ' ', 'foo', 5 );
* // returns 'beep foo'
* // returns 'beep boop'
*

@@ -41,0 +41,0 @@ * var out = replaceAfter( 'beep boop beep baz', 'beep', 'foo', 5 );

@@ -30,3 +30,3 @@ /**

* @param {integer} fromIndex - index at which to start the search
* @returns {string} - string
* @returns {string} output string
*

@@ -33,0 +33,0 @@ * @example

+1
-1

@@ -1,1 +0,1 @@

Copyright (c) 2016-2024 The Stdlib Authors.
Copyright (c) 2016-2026 The Stdlib Authors.
{
"name": "@stdlib/string-base-replace-after",
"version": "0.1.1",
"version": "0.1.2",
"description": "Replace the substring after the first occurrence of a specified search string.",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -153,2 +153,10 @@ <!--

* * *
## See Also
- <span class="package-name">[`@stdlib/string-base/replace-after-last`][@stdlib/string/base/replace-after-last]</span><span class="delimiter">: </span><span class="description">replace the substring after the last occurrence of a specified search string.</span>
- <span class="package-name">[`@stdlib/string-base/replace-before`][@stdlib/string/base/replace-before]</span><span class="delimiter">: </span><span class="description">replace the substring before the first occurrence of a specified search string.</span>
- <span class="package-name">[`@stdlib/string-base/replace-before-last`][@stdlib/string/base/replace-before-last]</span><span class="delimiter">: </span><span class="description">replace the substring before the last occurrence of a specified search string.</span>
</section>

@@ -184,3 +192,3 @@

Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].

@@ -198,4 +206,4 @@ </section>

[test-image]: https://github.com/stdlib-js/string-base-replace-after/actions/workflows/test.yml/badge.svg?branch=v0.1.1
[test-url]: https://github.com/stdlib-js/string-base-replace-after/actions/workflows/test.yml?query=branch:v0.1.1
[test-image]: https://github.com/stdlib-js/string-base-replace-after/actions/workflows/test.yml/badge.svg?branch=v0.1.2
[test-url]: https://github.com/stdlib-js/string-base-replace-after/actions/workflows/test.yml?query=branch:v0.1.2

@@ -212,4 +220,4 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-base-replace-after/main.svg

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
[chat-url]: https://stdlib.zulipchat.com

@@ -233,4 +241,14 @@ [stdlib]: https://github.com/stdlib-js/stdlib

<!-- <related-links> -->
[@stdlib/string/base/replace-after-last]: https://www.npmjs.com/package/@stdlib/string-base-replace-after-last
[@stdlib/string/base/replace-before]: https://www.npmjs.com/package/@stdlib/string-base-replace-before
[@stdlib/string/base/replace-before-last]: https://www.npmjs.com/package/@stdlib/string-base-replace-before-last
<!-- </related-links> -->
</section>
<!-- /.links -->