From a510f8e902217d2b8d61564bb6d3d5bf4194c58c Mon Sep 17 00:00:00 2001
From: HarshitaKalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sat, 4 Feb 2023 11:56:47 +0530
Subject: [PATCH 01/36] readme.md for replace-before
---
.../string/base/replace-before/README.md | 231 ++++++++++++++++++
1 file changed, 231 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/README.md
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
new file mode 100644
index 000000000000..da8e311635b6
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -0,0 +1,231 @@
+
+
+# replaceBefore
+
+> Replace the substring before the first occurrence of a specified search string.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var replaceBefore = require( '@stdlib/string/base/replace-before' );
+```
+
+#### replaceBefore( str, search, str2 )
+
+Replace the substring before the first occurrence of a specified search string.
+
+```javascript
+var str = 'beep boop';
+var out = replaceBefore( str, ' ', 'loop' );
+// returns 'loop boop'
+
+out = replaceBefore( str, 'o' , 'loop d');
+// returns 'loop doop'
+```
+
+
+
+
+
+
+
+
+
+## Notes
+
+- If a substring is not present in a provided string, the function returns the input string.
+- If provided an empty substring, the function returns an empty string.
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var substringBefore = require( '@stdlib/string/base/replace-before' );
+
+var out = substringBefore( 'beep boop', 'p', 'see' );
+// returns 'seep boop'
+
+out = substringBefore( 'Hello World!', 'xyz', 'abcd' );
+// returns 'Hello World!'
+
+out = substringBefore( 'Hello World!', '', 'abcd' );
+// returns ''
+
+out = substringBefore( '', 'xyz' , '');
+// returns ''
+```
+
+
+
+
+
+
+
+* * *
+
+
+
+## CLI
+
+
+
+
+
+### Usage
+
+```text
+Usage: replace-before [options] --search= []
+
+Options:
+
+ -h, --help Print this message.
+ -V, --version Print the package version.
+ --search string Search string.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
+```
+
+
+
+
+
+
+
+
+
+### Notes
+
+- If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
+
+ ```bash
+ # Not escaped...
+ $ echo -n $'foo\nbar\nbaz' | replace-before --search a --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'foo\nbar\nbaz' | replace-before --search a --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
+
+
+
+
+### Examples
+
+```bash
+$ replace-before abcdefg --search d --str2 pqr
+pqrdefg
+```
+
+To use as a [standard stream][standard-streams],
+
+```bash
+$ echo -n $'beep\nboop' | replace-before --search p --str2 see
+seep boop
+beep seep
+```
+
+By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option.
+
+```bash
+$ echo -n 'beep\tboop' | replace-before --search p --see --split '\t'
+seep boop
+beep seep
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
+
+
+[@stdlib/string/substring-before-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-before-last
+
+[@stdlib/string/substring-after]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-after
+
+[@stdlib/string/substring-after-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-after-last
+
+
+
+
+
+
From 37256238c7c6a0c70726101a0baaca7bc670fb80 Mon Sep 17 00:00:00 2001
From: HarshitaKalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sat, 4 Feb 2023 12:00:15 +0530
Subject: [PATCH 02/36] readme.md added for replace-before
---
.../@stdlib/string/base/replace-before/README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index da8e311635b6..04644fd8e985 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -40,7 +40,7 @@ limitations under the License.
var replaceBefore = require( '@stdlib/string/base/replace-before' );
```
-#### replaceBefore( str, search, str2 )
+#### replaceBefore( str, search, replacement )
Replace the substring before the first occurrence of a specified search string.
@@ -156,14 +156,14 @@ Options:
### Examples
```bash
-$ replace-before abcdefg --search d --str2 pqr
+$ replace-before abcdefg --search d --replacement pqr
pqrdefg
```
To use as a [standard stream][standard-streams],
```bash
-$ echo -n $'beep\nboop' | replace-before --search p --str2 see
+$ echo -n $'beep\nboop' | replace-before --search p --replacement see
seep boop
beep seep
```
From 42ef006235896e62a4e990e38a97399b9c284e06 Mon Sep 17 00:00:00 2001
From: HarshitaKalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sat, 4 Feb 2023 12:20:44 +0530
Subject: [PATCH 03/36] Added main.js for replace-before
---
.../string/base/replace-before/lib/main.js | 78 +++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
new file mode 100644
index 000000000000..706b05583522
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
@@ -0,0 +1,78 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns the part of a string before a specified substring.
+*
+* @param {string} str - input string
+* @param {string} search - search string
+* @param {string} replacement - replacement string
+* @throws {TypeError} first argument must be a string
+* @throws {TypeError} second argument must be a string
+* @throws {TypeError} third argument must be a string
+* @returns {string} string
+*
+* @example
+* var out = replaceBefore( 'beep boop', ' ', 'foo' );
+* // returns 'foo boop'
+*
+* @example
+* var out = replaceBefore( 'beep boop', 'p', 'foo' );
+* // returns 'foop boop'
+*
+* @example
+* var out = replaceBefore( 'Hello World!', '', 'foo' );
+* // returns ''
+*
+* @example
+* var out = replaceBefore( 'Hello World!', 'XYZ', 'foo' );
+* // returns 'Hello World!'
+*/
+function replaceBefore( str, search, replacement ) {
+ var idx;
+ if ( !isString( str ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
+ }
+ if ( !isString( search ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be a string. Value: `%s`.', search ) );
+ }
+ if ( !isString( replacement ) ) {
+ throw new TypeError( format( 'invalid argument. Third argument must be a string. Value: `%s`.', replacement ) );
+ }
+
+ idx = str.indexOf( search );
+ if ( idx === -1 ) {
+ return str;
+ }
+ return str.replace( str.substring( 0, idx ), replacement );
+}
+
+
+// EXPORTS //
+
+module.exports = replaceBefore;
\ No newline at end of file
From 864227e8b179e88d2c390d1153a5c869c553337d Mon Sep 17 00:00:00 2001
From: HarshitaKalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sat, 4 Feb 2023 12:28:48 +0530
Subject: [PATCH 04/36] updated a comment in main.js
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
.../@stdlib/string/base/replace-before/lib/index.js | 0
lib/node_modules/@stdlib/string/base/replace-before/lib/main.js | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 04644fd8e985..8bd3b61e80c4 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -42,7 +42,7 @@ var replaceBefore = require( '@stdlib/string/base/replace-before' );
#### replaceBefore( str, search, replacement )
-Replace the substring before the first occurrence of a specified search string.
+Replaces the substring before the first occurrence of a specified search string.
```javascript
var str = 'beep boop';
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
index 706b05583522..33600c875326 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
@@ -27,7 +27,7 @@ var format = require( '@stdlib/string/format' );
// MAIN //
/**
-* Returns the part of a string before a specified substring.
+* Replaces the substring before the first occurrence of a specified search string.
*
* @param {string} str - input string
* @param {string} search - search string
From 7a755144153de11a6cfda8e97f8a2d30d46b24b6 Mon Sep 17 00:00:00 2001
From: HarshitaKalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sat, 4 Feb 2023 12:40:29 +0530
Subject: [PATCH 05/36] index.js added in replace-before
---
.../string/base/replace-before/README.md | 10 ++--
.../string/base/replace-before/lib/index.js | 46 +++++++++++++++++++
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 8bd3b61e80c4..f290922105a5 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -46,11 +46,13 @@ Replaces the substring before the first occurrence of a specified search string.
```javascript
var str = 'beep boop';
-var out = replaceBefore( str, ' ', 'loop' );
+var replacement = 'loop';
+var out = replaceBefore( str, ' ', replacement );
// returns 'loop boop'
-out = replaceBefore( str, 'o' , 'loop d');
-// returns 'loop doop'
+replacement = 'bar';
+out = replaceBefore( str, 'o' , replacement);
+// returns 'baroop'
```
@@ -113,7 +115,7 @@ out = substringBefore( '', 'xyz' , '');
### Usage
```text
-Usage: replace-before [options] --search= []
+Usage: replace-before [options] --search= [] --replacement= []
Options:
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
index e69de29bb2d1..8fb629311b0e 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
@@ -0,0 +1,46 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Replace the substring before the first occurrence of a specified search string.
+*
+* @module @stdlib/string/base/replace-before
+*
+* @example
+* var replaceBefore = require( '@stdlib/string/substring-before' );
+*
+* var str = 'beep boop';
+* var replacement = 'foo';
+* var out = replaceBefore( str, ' ', replacement );
+* // returns 'foo boop'
+*
+* replacement = 'bar';
+* out = replaceBefore( str, 'o', replacement );
+* // returns 'baroop'
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
\ No newline at end of file
From 6049a76fe5afd34941d5a26a476f602357dc337e Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 13:33:11 +0530
Subject: [PATCH 06/36] benchmark.js added in replace-before
---
.../replace-before/benchmark/benchmark.js | 54 +++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
new file mode 100644
index 000000000000..55a839455e7d
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
@@ -0,0 +1,54 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var fromCodePoint = require( '@stdlib/string/from-code-point' );
+var pkg = require( './../package.json' ).name;
+var replaceBefore = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var out;
+ var str;
+ var replacement;
+ var i;
+
+ str = 'To be, or not to be, that is the question.';
+ replacement = 'foo';
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = replaceBefore( str, fromCodePoint( i%126 ), replacement );
+ if ( typeof out !== 'string' ) {
+ b.fail( 'should return a string' );
+ }
+ }
+ b.toc();
+ if ( !isString( out ) ) {
+ b.fail( 'should return a string' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
\ No newline at end of file
From 32e46a6caf401a8ddd1d9be8793861086cc2398c Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 16:13:02 +0530
Subject: [PATCH 07/36] updated main.js in replace-before
---
.../@stdlib/string/base/replace-before/lib/main.js | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
index 33600c875326..6e72e099c1a3 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
@@ -66,13 +66,10 @@ function replaceBefore( str, search, replacement ) {
}
idx = str.indexOf( search );
- if ( idx === -1 ) {
- return str;
- }
- return str.replace( str.substring( 0, idx ), replacement );
+
+ return replacement + str.substring( idx );
}
-
// EXPORTS //
module.exports = replaceBefore;
\ No newline at end of file
From ed769085961ab2a5c4dd3c98ba16a4f05a5d2f4e Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 16:25:16 +0530
Subject: [PATCH 08/36] examples added in replace-before
---
.../string/base/replace-before/README.md | 12 +++---
.../base/replace-before/examples/index.js | 37 +++++++++++++++++++
2 files changed, 43 insertions(+), 6 deletions(-)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index f290922105a5..418242664427 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -86,14 +86,14 @@ var substringBefore = require( '@stdlib/string/base/replace-before' );
var out = substringBefore( 'beep boop', 'p', 'see' );
// returns 'seep boop'
-out = substringBefore( 'Hello World!', 'xyz', 'abcd' );
-// returns 'Hello World!'
+out = substringBefore( 'Hello World!', 'xyz', 'foo' );
+// returns 'fooHello World!'
-out = substringBefore( 'Hello World!', '', 'abcd' );
-// returns ''
+out = substringBefore( 'Hello World!', '', 'foo' );
+// returns 'fooHello World!'
-out = substringBefore( '', 'xyz' , '');
-// returns ''
+out = substringBefore( '', 'xyz' , 'foo');
+// returns 'foo'
```
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
new file mode 100644
index 000000000000..b2b062618e5b
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
@@ -0,0 +1,37 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var replaceBefore = require( './../lib' );
+
+var out = replaceBefore( 'beep boop', 'p', 'foo' );
+console.log( out );
+// => 'bee'
+
+out = replaceBefore( 'Hello World!', 'xyz', 'foo' );
+console.log( out );
+// => 'Hello World!'
+
+out = replaceBefore( 'Hello World!', '', 'foo' );
+console.log( out );
+// => ''
+
+out = replaceBefore( '', 'xyz', 'foo' );
+console.log( out );
+// => ''
From 4de1adadcfd29910a20306cb95431ad3d9d3e6d2 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 16:50:55 +0530
Subject: [PATCH 09/36] test added in replace_before
---
.../test/fixtures/stdin_error.js.txt | 33 +++
.../base/replace-before/test/test.cli.js | 268 ++++++++++++++++++
.../string/base/replace-before/test/test.js | 202 +++++++++++++
3 files changed, 503 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/test/test.js
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt b/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
new file mode 100644
index 000000000000..6d8c83ded487
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
@@ -0,0 +1,33 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var proc = require( 'process' );
+var resolve = require( 'path' ).resolve;
+var proxyquire = require( 'proxyquire' );
+
+var fpath = resolve( __dirname, '..', 'bin', 'cli' );
+
+proc.stdin.isTTY = false;
+
+proxyquire( fpath, {
+ '@stdlib/process/read-stdin': stdin
+});
+
+function stdin( clbk ) {
+ clbk( new Error( 'beep' ) );
+}
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
new file mode 100644
index 000000000000..33b099462b93
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
@@ -0,0 +1,268 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var resolve = require( 'path' ).resolve;
+var exec = require( 'child_process' ).exec;
+var tape = require( 'tape' );
+var IS_BROWSER = require( '@stdlib/assert/is-browser' );
+var IS_WINDOWS = require( '@stdlib/assert/is-windows' );
+var EXEC_PATH = require( '@stdlib/process/exec-path' );
+var replace = require( '@stdlib/string/replace' );
+var readFileSync = require( '@stdlib/fs/read-file' ).sync;
+
+
+// VARIABLES //
+
+var fpath = resolve( __dirname, '..', 'bin', 'cli' );
+var opts = {
+ 'skip': IS_BROWSER || IS_WINDOWS
+};
+
+
+// FIXTURES //
+
+var PKG_VERSION = require( './../package.json' ).version;
+
+
+// TESTS //
+
+tape( 'command-line interface', function test( t ) {
+ t.ok( true, __filename );
+ t.end();
+});
+
+tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
+ var expected;
+ var cmd;
+
+ expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
+ 'encoding': 'utf8'
+ });
+ cmd = [
+ EXEC_PATH,
+ fpath,
+ '--help'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
+ t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
+ }
+ t.end();
+ }
+});
+
+tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
+ var expected;
+ var cmd;
+
+ expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
+ 'encoding': 'utf8'
+ });
+ cmd = [
+ EXEC_PATH,
+ fpath,
+ '-h'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
+ t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
+ }
+ t.end();
+ }
+});
+
+tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
+ var cmd = [
+ EXEC_PATH,
+ fpath,
+ '--version'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
+ t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
+ }
+ t.end();
+ }
+});
+
+tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
+ var cmd = [
+ EXEC_PATH,
+ fpath,
+ '-V'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
+ t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
+ }
+ t.end();
+ }
+});
+
+tape( 'the command-line interface prints the part of a string before a specified substring.', opts, function test( t ) {
+ var cmd = [
+ EXEC_PATH,
+ '-e',
+ '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=p\'; process.argv[ 3 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ var str;
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ str = stdout.toString();
+ t.strictEqual( str === 'boo\n', true, 'prints `beep` to `stdout`' );
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
+ }
+ t.end();
+ }
+});
+
+tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) {
+ var cmd = [
+ 'printf "beep boop\nboop beep"',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--search="e"'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
+ }
+ t.end();
+ }
+});
+
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'beep boop\tboop beep\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--search="e"',
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
+ }
+ t.end();
+ }
+});
+
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (regexp)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'beep boop\tboop beep\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--search="e"',
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
+ }
+ t.end();
+ }
+});
+
+tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) {
+ var script;
+ var opts;
+ var cmd;
+
+ script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), {
+ 'encoding': 'utf8'
+ });
+
+ // Replace single quotes with double quotes:
+ script = replace( script, '\'', '"' );
+
+ cmd = [
+ EXEC_PATH,
+ '-e',
+ '\''+script+'\''
+ ];
+
+ opts = {
+ 'cwd': __dirname
+ };
+
+ exec( cmd.join( ' ' ), opts, done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.pass( error.message );
+ t.strictEqual( error.code, 1, 'expected exit code' );
+ }
+ t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
+ t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' );
+ t.end();
+ }
+});
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
new file mode 100644
index 000000000000..f851237642a2
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
@@ -0,0 +1,202 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var replaceBefore = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof replaceBefore, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if not provided a string primitive as its first argument', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ 5,
+ NaN,
+ null,
+ void 0,
+ true,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ replaceBefore( value, 'beep', 'foo' );
+ };
+ }
+});
+
+tape( 'the function throws an error if not provided a string primitive as its second argument', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ 5,
+ NaN,
+ null,
+ void 0,
+ true,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ replaceBefore( 'beep boop', value, 'foo' );
+ };
+ }
+});
+
+tape( 'the function throws an error if not provided a string primitive as its third argument', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ 5,
+ NaN,
+ null,
+ void 0,
+ true,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ replaceBefore( 'beep boop', 'beep', value );
+ };
+ }
+});
+
+tape( 'the function replaces the substring before the first occurrence of a specified search string', function test( t ) {
+ var expected;
+ var actual;
+ var str;
+ var replacement;
+
+ str = 'beep boop';
+ replacement = 'foo';
+ actual = replaceBefore( str, ' ' , replacement );
+ expected = 'foo boop';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ str = 'beep boop';
+ replacement = 'foo';
+ actual = replaceBefore( str, 'p', replacement );
+ expected = 'foop boop';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ str = 'Hello, World!';
+ replacement = 'foo';
+ actual = replaceBefore( str, 'o', replacement );
+ expected = 'fooo, World!';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns the substring before a provided search string (Unicode characters)', function test( t ) {
+ var expected;
+ var actual;
+ var str;
+ var replacement;
+
+ str = 'beep 😀 boop 😀 baz';
+ replacement = 'foo';
+ actual = replaceBefore( str, '😀', replacement );
+ expected = 'foo😀 boop 😀 baz';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ str = '🤖 Robot army 🤖!';
+ replacement = 'foo';
+ actual = replaceBefore( str, '🤖', replacement );
+ expected = 'foo🤖 Robot army 🤖!';
+
+ str = '🐺 Wolf brothers 🐺';
+ replacement = 'foo';
+ actual = replaceBefore( str, 'o', replacement );
+ expected = 'fooolf brothers 🐺';
+
+ t.end();
+});
+
+tape( 'the function returns the entire string if the search string is not found', function test( t ) {
+ var expected;
+ var actual;
+ var str;
+ var replacement;
+
+ str = 'beep boop';
+ replacement = 'foo';
+ actual = replaceBefore( str, 'z', replacement );
+ expected = 'foobeep boop';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ str = 'beep boop';
+ replacement = 'foo';
+ actual = replaceBefore( str, 'baz', replacement );
+ expected = 'foobeep boop';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns the replacement string if the search string is the empty string', function test( t ) {
+ var expected;
+ var actual;
+ var str;
+ var replacement;
+
+ str = 'beep boop';
+ replacement = 'foo';
+ actual = replaceBefore( str, '' );
+ expected = 'foo';
+ t.strictEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});
\ No newline at end of file
From aeca05e27c9a2ecfa701b6f8812c7b5119c95c91 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 16:55:47 +0530
Subject: [PATCH 10/36] package.json added to replace_before
---
.../string/base/replace-before/package.json | 70 +++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/package.json
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/package.json b/lib/node_modules/@stdlib/string/base/replace-before/package.json
new file mode 100644
index 000000000000..b6fe7e4be8b2
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/package.json
@@ -0,0 +1,70 @@
+{
+ "name": "@stdlib/string/base/replace-before",
+ "version": "0.0.0",
+ "description": "Replace the substring before the first occurrence of a specified search string.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "bin": {
+ "substring-before": "./bin/cli"
+ },
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdstring",
+ "utilities",
+ "utility",
+ "utils",
+ "util",
+ "string",
+ "str",
+ "check",
+ "search",
+ "substring",
+ "substr",
+ "before",
+ "match"
+ ]
+ }
\ No newline at end of file
From 2611bde36ba78860b4bc66496864113797b33944 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 16:57:40 +0530
Subject: [PATCH 11/36] etc added to replace-before
---
.../base/replace-before/etc/cli_opts.json | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json b/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
new file mode 100644
index 000000000000..78a769f5e57f
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
@@ -0,0 +1,18 @@
+{
+ "string": [
+ "search",
+ "split"
+ ],
+ "boolean": [
+ "help",
+ "version"
+ ],
+ "alias": {
+ "help": [
+ "h"
+ ],
+ "version": [
+ "V"
+ ]
+ }
+}
\ No newline at end of file
From f2bad45c9ba8d2feaaf49ae1c95842f2a3297f26 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 17:08:30 +0530
Subject: [PATCH 12/36] docs added in replace_before
---
.../string/base/replace-before/docs/repl.txt | 31 ++++++++++
.../base/replace-before/docs/types/index.d.ts | 52 ++++++++++++++++
.../base/replace-before/docs/types/test.ts | 62 +++++++++++++++++++
.../string/base/replace-before/docs/usage.txt | 9 +++
4 files changed, 154 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
new file mode 100644
index 000000000000..9a5c733b35d7
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
@@ -0,0 +1,31 @@
+
+{{alias}}( str, search )
+ Replaces the substring before the first occurrence of a specified search string.
+
+ Parameters
+ ----------
+ str: string
+ Input string.
+
+ search: string
+ Search string.
+
+ replacement: string
+ Replacement string.
+
+ Returns
+ -------
+ out: string
+ string.
+
+ Examples
+ --------
+ > var str = 'beep boop';
+ > var replacement = 'foo';
+ > var out = {{alias}}( str, ' ', replacement )
+ 'fooboop'
+ > out = {{alias}}( str, 'o', replacement )
+ 'foooop'
+
+ See Also
+ --------
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
new file mode 100644
index 000000000000..3c1e2d82ece6
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
@@ -0,0 +1,52 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 2.0
+
+///
+
+/**
+* Replace the substring before the first occurrence of a specified search string.
+*
+* @param str - input string
+* @param search - search string
+* @param replacement - replacement string
+* @returns substring
+*
+* @example
+* var out = replaceBefore( 'beep boop', ' ', 'foo' );
+* // returns 'foo boop'
+*
+* @example
+* var out = replaceBefore( 'beep boop', 'p', 'foo' );
+* // returns 'foop boop'
+*
+* @example
+* var out = replaceBefore( 'Hello World!', '', 'foo' );
+* // returns 'fooHello world!'
+*
+* @example
+* var out = replaceBefore( 'Hello World!', 'XYZ', 'foo' );
+* // returns 'fooHello World!'
+*/
+declare function replaceBefore( str: string, search: string, replacement: string ): string;
+
+
+// EXPORTS //
+
+export = replaceBefore;
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
new file mode 100644
index 000000000000..42f3eb1395fa
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -0,0 +1,62 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import replaceBefore = require( './index' );
+
+
+// TESTS //
+
+// The function returns a string...
+{
+ replaceBefore( 'beep boop', ' ', 'foo' ); // $ExpectType string
+ replaceBefore( 'beep boop', 'xyz', 'foo' ); // $ExpectType string
+ replaceBefore( 'beep boop', '', 'foo' ); // $ExpectType string
+}
+
+// The compiler throws an error if the function is provided arguments having invalid types...
+{
+ replaceBefore( true, 'd', 'foo' ); // $ExpectError
+ replaceBefore( false, 'd' , 'foo'); // $ExpectError
+ replaceBefore( 3, 'd' , 'foo'); // $ExpectError
+ replaceBefore( [], 'd' , 'foo'); // $ExpectError
+ replaceBefore( {}, 'd' , 'foo'); // $ExpectError
+ replaceBefore( ( x: number ): number => x, 'd', 'foo' ); // $ExpectError
+
+ replaceBefore( 'abc', true, 'foo' ); // $ExpectError
+ replaceBefore( 'abc', false, 'foo' ); // $ExpectError
+ replaceBefore( 'abc', 5 , 'foo'); // $ExpectError
+ replaceBefore( 'abc', [], 'foo' ); // $ExpectError
+ replaceBefore( 'abc', {} , 'foo'); // $ExpectError
+ replaceBefore( 'abc', ( x: number ): number => x , 'foo'); // $ExpectError
+
+ replaceBefore( 'abc', 'd', true ); // $ExpectError
+ replaceBefore( 'abc', 'd', false ); // $ExpectError
+ replaceBefore( 'abc', 'd', 5 ); // $ExpectError
+ replaceBefore( 'abc', 'd', [] ); // $ExpectError
+ replaceBefore( 'abc', 'd', {} ); // $ExpectError
+ replaceBefore( 'abc', 'd', ( x: number ): number => x ); // $ExpectError
+
+}
+
+// The compiler throws an error if the function is provided insufficient arguments...
+{
+ replaceBefore(); // $ExpectError
+ replaceBefore( 'abc' ); // $ExpectError
+ replaceBefore( 'abc', 'd' ); // $ExpectError
+
+}
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
new file mode 100644
index 000000000000..1bd5eeec2860
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
@@ -0,0 +1,9 @@
+
+Usage: replace-before [options] --search= []
+
+Options:
+
+ -h, --help Print this message.
+ -V, --version Print the package version.
+ --search string Search string.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
\ No newline at end of file
From fbc12e2d06f1c8442b6f2e45aa8bf02202a55fb9 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sat, 4 Feb 2023 17:11:03 +0530
Subject: [PATCH 13/36] added bin in replace_before
---
.../string/base/replace-before/bin/cli | 116 ++++++++++++++++++
1 file changed, 116 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-before/bin/cli
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/bin/cli b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
new file mode 100644
index 000000000000..a4210ca4d129
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
@@ -0,0 +1,116 @@
+#!/usr/bin/env node
+
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var resolve = require( 'path' ).resolve;
+var readFileSync = require( '@stdlib/fs/read-file' ).sync;
+var CLI = require( '@stdlib/cli/ctor' );
+var stdin = require( '@stdlib/process/read-stdin' );
+var stdinStream = require( '@stdlib/streams/node/stdin' );
+var RE_EOL = require( '@stdlib/regexp/eol' ).REGEXP;
+var isRegExpString = require( '@stdlib/assert/is-regexp-string' );
+var reFromString = require( '@stdlib/utils/regexp-from-string' );
+var replaceBefore = require( './../lib' );
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+* @returns {void}
+*/
+function main() {
+ var split;
+ var flags;
+ var args;
+ var cli;
+ var str;
+
+ // Create a command-line interface:
+ cli = new CLI({
+ 'pkg': require( './../package.json' ),
+ 'options': require( './../etc/cli_opts.json' ),
+ 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
+ 'encoding': 'utf8'
+ })
+ });
+
+ // Get any provided command-line options:
+ flags = cli.flags();
+ if ( flags.help || flags.version ) {
+ return;
+ }
+
+ // Get any provided command-line arguments:
+ args = cli.args();
+
+ if ( args.length ) {
+ str = args[ 0 ];
+ replacement = args[ 1 ];
+ } else {
+ // Treat an empty value as an empty string:
+ str = '';
+ }
+ // Check if we are receiving data from `stdin`...
+ if ( !stdinStream.isTTY ) {
+ if ( flags.split ) {
+ if ( !isRegExpString( flags.split ) ) {
+ flags.split = '/'+flags.split+'/';
+ }
+ split = reFromString( flags.split );
+ } else {
+ split = RE_EOL;
+ }
+ return stdin( onRead );
+ }
+ console.log( replaceBefore( str, flags.search, replacement) ); // eslint-disable-line no-console
+
+ /**
+ * Callback invoked upon reading from `stdin`.
+ *
+ * @private
+ * @param {(Error|null)} error - error object
+ * @param {Buffer} data - data
+ * @returns {void}
+ */
+ function onRead( error, data ) {
+ var lines;
+ var i;
+ if ( error ) {
+ return cli.error( error );
+ }
+ lines = data.toString().split( split );
+
+ // Remove any trailing separators (e.g., trailing newline)...
+ if ( lines[ lines.length-1 ] === '' ) {
+ lines.pop();
+ }
+ for ( i = 0; i < lines.length; i++ ) {
+ console.log( replaceBefore( lines[ i ], flags.search, replacement ) ); // eslint-disable-line no-console
+ }
+ }
+}
+
+main();
\ No newline at end of file
From d9391fadc5d918588d758fcdbdff8deafd5f64f1 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sun, 5 Feb 2023 12:34:13 +0530
Subject: [PATCH 14/36] updated 2021 to 2023 in all files
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
.../@stdlib/string/base/replace-before/benchmark/benchmark.js | 2 +-
lib/node_modules/@stdlib/string/base/replace-before/bin/cli | 2 +-
.../@stdlib/string/base/replace-before/docs/types/index.d.ts | 2 +-
.../@stdlib/string/base/replace-before/docs/types/test.ts | 2 +-
.../@stdlib/string/base/replace-before/examples/index.js | 2 +-
.../@stdlib/string/base/replace-before/lib/index.js | 2 +-
lib/node_modules/@stdlib/string/base/replace-before/lib/main.js | 2 +-
.../string/base/replace-before/test/fixtures/stdin_error.js.txt | 2 +-
.../@stdlib/string/base/replace-before/test/test.cli.js | 2 +-
.../@stdlib/string/base/replace-before/test/test.js | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 418242664427..b2872a44058a 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -2,7 +2,7 @@
@license Apache-2.0
-Copyright (c) 2021 The Stdlib Authors.
+Copyright (c) 2023 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
index 55a839455e7d..95a64414abea 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/bin/cli b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
index a4210ca4d129..010ef1434a24 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
+++ b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
@@ -3,7 +3,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
index 3c1e2d82ece6..7ab84dd8b17e 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
index 42f3eb1395fa..41bd19477c66 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
index b2b062618e5b..66ccdc38c23f 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
index 8fb629311b0e..e95f2b37c546 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
index 6e72e099c1a3..317222628cf5 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt b/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
index 6d8c83ded487..3fc7f8c12cea 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/fixtures/stdin_error.js.txt
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
index 33b099462b93..198b59dbf2a3 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
index f851237642a2..36b5a99a0df3 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2021 The Stdlib Authors.
+* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
From 58b88e961673f1792766220bc4dbe670aec8c1a3 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sun, 5 Feb 2023 12:42:30 +0530
Subject: [PATCH 15/36] indeantation added in readme.md
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index b2872a44058a..b003efd19d3b 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -51,7 +51,7 @@ var out = replaceBefore( str, ' ', replacement );
// returns 'loop boop'
replacement = 'bar';
-out = replaceBefore( str, 'o' , replacement);
+out = replaceBefore( str, 'o' , replacement );
// returns 'baroop'
```
From 1b8fad06ebc714ef93c4aa1d206b270e6567206f Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Sun, 12 Feb 2023 16:53:20 +0530
Subject: [PATCH 16/36] made the required changes after review
---
.../replace-before/benchmark/benchmark.js | 2 +-
.../base/replace-before/docs/types/index.d.ts | 6 +--
.../base/replace-before/examples/index.js | 4 +-
.../string/base/replace-before/lib/index.js | 4 +-
.../string/base/replace-before/lib/main.js | 9 +++--
.../string/base/replace-before/package.json | 6 +--
.../base/replace-before/test/test.cli.js | 15 ++++---
.../string/base/replace-before/test/test.js | 40 +++++++++----------
package.json | 22 ++++------
9 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
index 95a64414abea..d3adfb16e616 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
@@ -32,7 +32,7 @@ var replaceBefore = require( './../lib' );
bench( pkg, function benchmark( b ) {
var out;
var str;
- var replacement;
+ var replacement;
var i;
str = 'To be, or not to be, that is the question.';
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
index 7ab84dd8b17e..040332850802 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
@@ -38,15 +38,15 @@
*
* @example
* var out = replaceBefore( 'Hello World!', '', 'foo' );
-* // returns 'fooHello world!'
+* // returns 'Hello world!'
*
* @example
* var out = replaceBefore( 'Hello World!', 'XYZ', 'foo' );
-* // returns 'fooHello World!'
+* // returns 'Hello World!'
*/
declare function replaceBefore( str: string, search: string, replacement: string ): string;
// EXPORTS //
-export = replaceBefore;
\ No newline at end of file
+export = replaceBefore;
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
index 66ccdc38c23f..97caf301171b 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/examples/index.js
@@ -22,7 +22,7 @@ var replaceBefore = require( './../lib' );
var out = replaceBefore( 'beep boop', 'p', 'foo' );
console.log( out );
-// => 'bee'
+// => 'foop boop'
out = replaceBefore( 'Hello World!', 'xyz', 'foo' );
console.log( out );
@@ -30,7 +30,7 @@ console.log( out );
out = replaceBefore( 'Hello World!', '', 'foo' );
console.log( out );
-// => ''
+// => 'Hello World!'
out = replaceBefore( '', 'xyz', 'foo' );
console.log( out );
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
index e95f2b37c546..274f896de0d4 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/index.js
@@ -29,7 +29,7 @@
* var str = 'beep boop';
* var replacement = 'foo';
* var out = replaceBefore( str, ' ', replacement );
-* // returns 'foo boop'
+* // returns 'beep boop'
*
* replacement = 'bar';
* out = replaceBefore( str, 'o', replacement );
@@ -43,4 +43,4 @@ var main = require( './main.js' );
// EXPORTS //
-module.exports = main;
\ No newline at end of file
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
index 317222628cf5..57ee7d35966e 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/lib/main.js
@@ -39,7 +39,7 @@ var format = require( '@stdlib/string/format' );
*
* @example
* var out = replaceBefore( 'beep boop', ' ', 'foo' );
-* // returns 'foo boop'
+* // returns 'beep boop'
*
* @example
* var out = replaceBefore( 'beep boop', 'p', 'foo' );
@@ -47,7 +47,7 @@ var format = require( '@stdlib/string/format' );
*
* @example
* var out = replaceBefore( 'Hello World!', '', 'foo' );
-* // returns ''
+* // returns 'Hello World!'
*
* @example
* var out = replaceBefore( 'Hello World!', 'XYZ', 'foo' );
@@ -67,9 +67,12 @@ function replaceBefore( str, search, replacement ) {
idx = str.indexOf( search );
+ if ( str === '' || search === '' || replacement === '' || idx < 0 ) {
+ return str;
+ }
return replacement + str.substring( idx );
}
// EXPORTS //
-module.exports = replaceBefore;
\ No newline at end of file
+module.exports = replaceBefore;
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/package.json b/lib/node_modules/@stdlib/string/base/replace-before/package.json
index b6fe7e4be8b2..e10a3cda8107 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/package.json
+++ b/lib/node_modules/@stdlib/string/base/replace-before/package.json
@@ -14,7 +14,7 @@
}
],
"bin": {
- "substring-before": "./bin/cli"
+ "replace-before": "./bin/cli"
},
"main": "./lib",
"directories": {
@@ -60,11 +60,11 @@
"util",
"string",
"str",
- "check",
+ "replace",
"search",
"substring",
"substr",
"before",
"match"
]
- }
\ No newline at end of file
+ }
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
index 198b59dbf2a3..f05766dc2267 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
@@ -142,11 +142,11 @@ tape( 'when invoked with a `-V` flag, the command-line interface prints the vers
}
});
-tape( 'the command-line interface prints the part of a string before a specified substring.', opts, function test( t ) {
+tape( 'the command-line interface replaces the substring before the first occurrence of a specified search string', opts, function test( t ) {
var cmd = [
EXEC_PATH,
'-e',
- '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=p\'; process.argv[ 3 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
+ '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=p\'; process.argv[ 3 ] = \'boopbeep\'; process.argv[4] = \'--replacement=foo\'; require( \''+fpath+'\' );"'
];
exec( cmd.join( ' ' ), done );
@@ -170,7 +170,8 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
'|',
EXEC_PATH,
fpath,
- '--search="e"'
+ '--search="e"',
+ '--replacement="foo"'
];
exec( cmd.join( ' ' ), done );
@@ -179,7 +180,7 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
if ( error ) {
t.fail( error.message );
} else {
- t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stdout.toString(), 'fooeep boop\nfooeep\n', 'expected value' );
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
}
t.end();
@@ -193,6 +194,7 @@ tape( 'the command-line interface supports specifying a custom delimiter when us
EXEC_PATH,
fpath,
'--search="e"',
+ '--replacement="foo"',
'--split \'\t\''
];
@@ -202,7 +204,7 @@ tape( 'the command-line interface supports specifying a custom delimiter when us
if ( error ) {
t.fail( error.message );
} else {
- t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stdout.toString(), 'fooeep boop\nfooeep\n', 'expected value' );
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
}
t.end();
@@ -216,6 +218,7 @@ tape( 'the command-line interface supports specifying a custom delimiter when us
EXEC_PATH,
fpath,
'--search="e"',
+ '--replacement="foo"',
'--split=/\\\\t/'
];
@@ -265,4 +268,4 @@ tape( 'when used as a standard stream, if an error is encountered when reading f
t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' );
t.end();
}
-});
\ No newline at end of file
+});
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
index 36b5a99a0df3..d61e8d9e6ae9 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.js
@@ -32,7 +32,7 @@ tape( 'main export is a function', function test( t ) {
t.end();
});
-tape( 'the function throws an error if not provided a string primitive as its first argument', function test( t ) {
+tape( 'the function throws an error if not provided a string as its first argument', function test( t ) {
var values;
var i;
@@ -59,7 +59,7 @@ tape( 'the function throws an error if not provided a string primitive as its fi
}
});
-tape( 'the function throws an error if not provided a string primitive as its second argument', function test( t ) {
+tape( 'the function throws an error if not provided a string as its second argument', function test( t ) {
var values;
var i;
@@ -86,7 +86,7 @@ tape( 'the function throws an error if not provided a string primitive as its se
}
});
-tape( 'the function throws an error if not provided a string primitive as its third argument', function test( t ) {
+tape( 'the function throws an error if not provided a string as its third argument', function test( t ) {
var values;
var i;
@@ -117,22 +117,22 @@ tape( 'the function replaces the substring before the first occurrence of a spec
var expected;
var actual;
var str;
- var replacement;
+ var replacement;
str = 'beep boop';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, ' ' , replacement );
expected = 'foo boop';
t.strictEqual( actual, expected, 'returns expected value' );
str = 'beep boop';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, 'p', replacement );
expected = 'foop boop';
t.strictEqual( actual, expected, 'returns expected value' );
str = 'Hello, World!';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, 'o', replacement );
expected = 'fooo, World!';
t.strictEqual( actual, expected, 'returns expected value' );
@@ -140,25 +140,25 @@ tape( 'the function replaces the substring before the first occurrence of a spec
t.end();
});
-tape( 'the function returns the substring before a provided search string (Unicode characters)', function test( t ) {
+tape( 'the function replaces the substring before the first occurrence of a specified search string (Unicode characters)', function test( t ) {
var expected;
var actual;
var str;
- var replacement;
+ var replacement;
str = 'beep 😀 boop 😀 baz';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, '😀', replacement );
expected = 'foo😀 boop 😀 baz';
t.strictEqual( actual, expected, 'returns expected value' );
str = '🤖 Robot army 🤖!';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, '🤖', replacement );
expected = 'foo🤖 Robot army 🤖!';
str = '🐺 Wolf brothers 🐺';
- replacement = 'foo';
+ replacement = 'foo';
actual = replaceBefore( str, 'o', replacement );
expected = 'fooolf brothers 🐺';
@@ -169,34 +169,34 @@ tape( 'the function returns the entire string if the search string is not found'
var expected;
var actual;
var str;
- var replacement;
+ var replacement;
str = 'beep boop';
replacement = 'foo';
actual = replaceBefore( str, 'z', replacement );
- expected = 'foobeep boop';
+ expected = 'beep boop';
t.strictEqual( actual, expected, 'returns expected value' );
str = 'beep boop';
replacement = 'foo';
actual = replaceBefore( str, 'baz', replacement );
- expected = 'foobeep boop';
+ expected = 'beep boop';
t.strictEqual( actual, expected, 'returns expected value' );
t.end();
});
-tape( 'the function returns the replacement string if the search string is the empty string', function test( t ) {
+tape( 'the function returns the entire string if the search string is the empty string', function test( t ) {
var expected;
var actual;
var str;
- var replacement;
+ var replacement;
str = 'beep boop';
replacement = 'foo';
- actual = replaceBefore( str, '' );
- expected = 'foo';
+ actual = replaceBefore( str, '', replacement );
+ expected = 'beep boop';
t.strictEqual( actual, expected, 'returns expected value' );
t.end();
-});
\ No newline at end of file
+});
diff --git a/package.json b/package.json
index 620394bb4e87..93c3d499b9b1 100644
--- a/package.json
+++ b/package.json
@@ -3,32 +3,26 @@
"version": "0.0.96",
"description": "Standard library.",
"license": "Apache-2.0 AND BSL-1.0",
- "author": {
- "name": "The Stdlib Authors",
- "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
- },
+ "author": "The Stdlib Authors (https://github.com/stdlib-js/stdlib/graphs/contributors)",
"contributors": [
- {
- "name": "The Stdlib Authors",
- "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
- }
+ "The Stdlib Authors (https://github.com/stdlib-js/stdlib/graphs/contributors)"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/stdlib"
},
"bin": {
- "stdlib": "./bin/cli"
+ "stdlib": "bin/cli"
},
"main": "./lib",
"browser": {
"process": "process/"
},
"directories": {
- "doc": "./docs",
- "example": "./examples",
- "lib": "./lib",
- "test": "./test"
+ "doc": "docs",
+ "example": "examples",
+ "lib": "lib",
+ "test": "test"
},
"types": "./docs/types",
"scripts": {
@@ -123,7 +117,7 @@
"eslint": "^8.0.1",
"eslint-plugin-node": "^11.1.0",
"factor-bundle": "^2.5.0",
- "gh-pages": "git+https://github.com/Planeshifter/gh-pages#main",
+ "gh-pages": "git+https://github.com/Planeshifter/gh-pages.git#main",
"jsdoc": "^3.4.0",
"lunr": "^2.3.9",
"mathjax-node": "^2.0.1",
From fee7998dceb1aa61c1832e850fa006c9366cffbc Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:52:58 +0530
Subject: [PATCH 17/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index b003efd19d3b..6cfbb211abaf 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -115,7 +115,7 @@ out = substringBefore( '', 'xyz' , 'foo');
### Usage
```text
-Usage: replace-before [options] --search= [] --replacement= []
+Usage: replace-before [options] --search= --replacement= []
Options:
From 6b45090bd34ed47b08dd68bc3295a1203154a5c6 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:53:52 +0530
Subject: [PATCH 18/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/README.md | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 6cfbb211abaf..e50707568fe8 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -45,13 +45,10 @@ var replaceBefore = require( '@stdlib/string/base/replace-before' );
Replaces the substring before the first occurrence of a specified search string.
```javascript
-var str = 'beep boop';
-var replacement = 'loop';
-var out = replaceBefore( str, ' ', replacement );
+var out = replaceBefore( 'beep boop', ' ', 'loop' );
// returns 'loop boop'
-replacement = 'bar';
-out = replaceBefore( str, 'o' , replacement );
+out = replaceBefore( 'beep boop', 'o', 'bar' );
// returns 'baroop'
```
From 1f1fe5568b9453e0154c7997e013debac7f3a931 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:54:02 +0530
Subject: [PATCH 19/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index e50707568fe8..1a2d4033812c 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -62,7 +62,7 @@ out = replaceBefore( 'beep boop', 'o', 'bar' );
## Notes
-- If a substring is not present in a provided string, the function returns the input string.
+- If a search string is not present in a provided string, the function returns the provided string unchanged.
- If provided an empty substring, the function returns an empty string.
From a83781147684f400ff18e6dcf3f173f7d98c0c2f Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:54:18 +0530
Subject: [PATCH 20/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 1a2d4033812c..a2e122855a97 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -63,7 +63,6 @@ out = replaceBefore( 'beep boop', 'o', 'bar' );
## Notes
- If a search string is not present in a provided string, the function returns the provided string unchanged.
-- If provided an empty substring, the function returns an empty string.
From 7485791ac76e06e6913024a955810ec911a2043a Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:58:57 +0530
Subject: [PATCH 21/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/README.md | 8 --------
1 file changed, 8 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index a2e122855a97..ea2ee6b6124f 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -194,14 +194,6 @@ beep seep
From e5a2d719e8a2379c2044cc462e5ea9ba13645da9 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:59:10 +0530
Subject: [PATCH 22/36] Update
lib/node_modules/@stdlib/string/base/replace-before/README.md
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/README.md | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index ea2ee6b6124f..559683143c2b 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -206,16 +206,6 @@ beep seep
[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
-
-
-[@stdlib/string/substring-before-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-before-last
-
-[@stdlib/string/substring-after]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-after
-
-[@stdlib/string/substring-after-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-after-last
-
-
-
From 9875414dff87de903a93f1b5a184f792351da381 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 19:59:20 +0530
Subject: [PATCH 23/36] Update
lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
Co-authored-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
---
.../@stdlib/string/base/replace-before/benchmark/benchmark.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
index d3adfb16e616..8ef80e149efe 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/benchmark/benchmark.js
@@ -36,7 +36,7 @@ bench( pkg, function benchmark( b ) {
var i;
str = 'To be, or not to be, that is the question.';
- replacement = 'foo';
+ replacement = 'foo';
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
From e74289cf0697a97952f7f478c759e71b84ed93b1 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:30:45 +0530
Subject: [PATCH 24/36] Update
lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/docs/repl.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
index 9a5c733b35d7..e4492ce3f040 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
@@ -1,5 +1,5 @@
-{{alias}}( str, search )
+{{alias}}( str, search, replacement )
Replaces the substring before the first occurrence of a specified search string.
Parameters
From 3d2838b8a6bfe1087b76dc5d51fd8c3f10d36bc1 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:30:59 +0530
Subject: [PATCH 25/36] Update
lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/docs/repl.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
index e4492ce3f040..2c6462e29f67 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
@@ -16,7 +16,7 @@
Returns
-------
out: string
- string.
+ Output string.
Examples
--------
From da64037aab744af39c0f3cb7a839bc4535468b4f Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:33:38 +0530
Subject: [PATCH 26/36] Update
lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/docs/types/index.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
index 040332850802..00aa9db1946b 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
@@ -21,7 +21,7 @@
///
/**
-* Replace the substring before the first occurrence of a specified search string.
+* Replaces the substring before the first occurrence of a specified search string.
*
* @param str - input string
* @param search - search string
From 927bb0e30c49f48ace4aa5113fc80c31a8e4ce14 Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:34:07 +0530
Subject: [PATCH 27/36] Update
lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/docs/types/test.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
index 41bd19477c66..e2de0f7aac92 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -50,7 +50,6 @@ import replaceBefore = require( './index' );
replaceBefore( 'abc', 'd', [] ); // $ExpectError
replaceBefore( 'abc', 'd', {} ); // $ExpectError
replaceBefore( 'abc', 'd', ( x: number ): number => x ); // $ExpectError
-
}
// The compiler throws an error if the function is provided insufficient arguments...
From 4de2f2375b7442b2d7a79118ac546523d4ba1e5c Mon Sep 17 00:00:00 2001
From: Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:34:31 +0530
Subject: [PATCH 28/36] Update
lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
Co-authored-by: Athan
---
.../@stdlib/string/base/replace-before/docs/types/test.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
index e2de0f7aac92..954aab75cf62 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -57,5 +57,4 @@ import replaceBefore = require( './index' );
replaceBefore(); // $ExpectError
replaceBefore( 'abc' ); // $ExpectError
replaceBefore( 'abc', 'd' ); // $ExpectError
-
}
\ No newline at end of file
From 5357956d1e0c489d13e1efea28509056a55c8f5f Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Mon, 13 Feb 2023 10:53:16 +0530
Subject: [PATCH 29/36] updated the changes
---
.../string/base/replace-before/README.md | 23 ++++++++++---------
.../string/base/replace-before/bin/cli | 7 +++---
.../string/base/replace-before/docs/repl.txt | 10 ++++----
.../base/replace-before/docs/types/test.ts | 2 +-
.../string/base/replace-before/docs/usage.txt | 3 ++-
.../base/replace-before/etc/cli_opts.json | 3 ++-
.../string/base/replace-before/package.json | 14 +++++------
7 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index b003efd19d3b..7a63288968cd 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -51,7 +51,7 @@ var out = replaceBefore( str, ' ', replacement );
// returns 'loop boop'
replacement = 'bar';
-out = replaceBefore( str, 'o' , replacement );
+out = replaceBefore( str, 'o', replacement );
// returns 'baroop'
```
@@ -87,13 +87,13 @@ var out = substringBefore( 'beep boop', 'p', 'see' );
// returns 'seep boop'
out = substringBefore( 'Hello World!', 'xyz', 'foo' );
-// returns 'fooHello World!'
+// returns 'Hello World!'
out = substringBefore( 'Hello World!', '', 'foo' );
-// returns 'fooHello World!'
+// returns 'Hello World!'
-out = substringBefore( '', 'xyz' , 'foo');
-// returns 'foo'
+out = substringBefore( '', 'xyz', 'foo');
+// returns ''
```
@@ -122,6 +122,7 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--search string Search string.
+ --replacement string Replacement string.
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
```
@@ -139,10 +140,10 @@ Options:
```bash
# Not escaped...
- $ echo -n $'foo\nbar\nbaz' | replace-before --search a --split /\r?\n/
+ $ echo -n $'foo\nbar\nbaz' | replace-before --search a --replacement b --split /\r?\n/
# Escaped...
- $ echo -n $'foo\nbar\nbaz' | replace-before --search a --split /\\r?\\n/
+ $ echo -n $'foo\nbar\nbaz' | replace-before --search a --replacement b --split /\\r?\\n/
```
- The implementation ignores trailing delimiters.
@@ -166,16 +167,16 @@ To use as a [standard stream][standard-streams],
```bash
$ echo -n $'beep\nboop' | replace-before --search p --replacement see
-seep boop
-beep seep
+seep
+seep
```
By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option.
```bash
$ echo -n 'beep\tboop' | replace-before --search p --see --split '\t'
-seep boop
-beep seep
+seep
+seep
```
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/bin/cli b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
index 010ef1434a24..f877ab781457 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
+++ b/lib/node_modules/@stdlib/string/base/replace-before/bin/cli
@@ -68,7 +68,6 @@ function main() {
if ( args.length ) {
str = args[ 0 ];
- replacement = args[ 1 ];
} else {
// Treat an empty value as an empty string:
str = '';
@@ -85,7 +84,7 @@ function main() {
}
return stdin( onRead );
}
- console.log( replaceBefore( str, flags.search, replacement) ); // eslint-disable-line no-console
+ console.log( replaceBefore( str, flags.search, flags.replacement) );
/**
* Callback invoked upon reading from `stdin`.
@@ -108,9 +107,9 @@ function main() {
lines.pop();
}
for ( i = 0; i < lines.length; i++ ) {
- console.log( replaceBefore( lines[ i ], flags.search, replacement ) ); // eslint-disable-line no-console
+ console.log(replaceBefore( lines[ i ], flags.search, flags.replacement ) ); // eslint-disable-line max-len
}
}
}
-main();
\ No newline at end of file
+main();
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
index 9a5c733b35d7..f0f3364b3519 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
@@ -1,6 +1,7 @@
{{alias}}( str, search )
- Replaces the substring before the first occurrence of a specified search string.
+ Replaces the substring before the first occurrence of a specified
+ search string.
Parameters
----------
@@ -16,16 +17,17 @@
Returns
-------
out: string
- string.
+ String.
Examples
--------
> var str = 'beep boop';
> var replacement = 'foo';
> var out = {{alias}}( str, ' ', replacement )
- 'fooboop'
+ 'foo boop'
> out = {{alias}}( str, 'o', replacement )
'foooop'
See Also
- --------
\ No newline at end of file
+ --------
+
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
index 41bd19477c66..d32e87dea9d2 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -59,4 +59,4 @@ import replaceBefore = require( './index' );
replaceBefore( 'abc' ); // $ExpectError
replaceBefore( 'abc', 'd' ); // $ExpectError
-}
\ No newline at end of file
+}
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
index 1bd5eeec2860..ae56e68867a5 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/usage.txt
@@ -6,4 +6,5 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--search string Search string.
- --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
\ No newline at end of file
+ --replacement string Replacement string.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json b/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
index 78a769f5e57f..ef139893a8e3 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
+++ b/lib/node_modules/@stdlib/string/base/replace-before/etc/cli_opts.json
@@ -1,6 +1,7 @@
{
"string": [
"search",
+ "replacement",
"split"
],
"boolean": [
@@ -15,4 +16,4 @@
"V"
]
}
-}
\ No newline at end of file
+}
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/package.json b/lib/node_modules/@stdlib/string/base/replace-before/package.json
index e10a3cda8107..1c708ff06ec0 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/package.json
+++ b/lib/node_modules/@stdlib/string/base/replace-before/package.json
@@ -1,6 +1,6 @@
{
"name": "@stdlib/string/base/replace-before",
- "version": "0.0.0",
+ "version": "0.0.96",
"description": "Replace the substring before the first occurrence of a specified search string.",
"license": "Apache-2.0",
"author": {
@@ -14,15 +14,15 @@
}
],
"bin": {
- "replace-before": "./bin/cli"
+ "replace-before": "bin/cli"
},
"main": "./lib",
"directories": {
- "benchmark": "./benchmark",
- "doc": "./docs",
- "example": "./examples",
- "lib": "./lib",
- "test": "./test"
+ "benchmark": "benchmark",
+ "doc": "docs",
+ "example": "examples",
+ "lib": "lib",
+ "test": "test"
},
"types": "./docs/types",
"scripts": {},
From b9a5ed3d1af92941623ebae506168ae71f3ec5b6 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Wed, 22 Feb 2023 14:17:30 +0530
Subject: [PATCH 30/36] lint errors and cli test cases resolved
---
.../@stdlib/string/base/replace-before/test/test.cli.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
index f05766dc2267..81a4f77bf07a 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
+++ b/lib/node_modules/@stdlib/string/base/replace-before/test/test.cli.js
@@ -157,7 +157,7 @@ tape( 'the command-line interface replaces the substring before the first occurr
t.fail( error.message );
} else {
str = stdout.toString();
- t.strictEqual( str === 'boo\n', true, 'prints `beep` to `stdout`' );
+ t.strictEqual( str === 'foopbeep\n', true, 'prints `beep` to `stdout`' );
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
}
t.end();
@@ -228,7 +228,7 @@ tape( 'the command-line interface supports specifying a custom delimiter when us
if ( error ) {
t.fail( error.message );
} else {
- t.strictEqual( stdout.toString(), 'b\nboop b\n', 'expected value' );
+ t.strictEqual( stdout.toString(), 'fooeep boop\nfooeep\n', 'expected value' );
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
}
t.end();
From 381c32ca559600d355241775896e817b60ed0245 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 10:15:35 +0530
Subject: [PATCH 31/36] updation in docs
---
.../base/replace-before/docs/types/index.d.ts | 2 +-
.../base/replace-before/docs/types/test.ts | 30 +++++++++----------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
index 00aa9db1946b..4c681b872e7c 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/index.d.ts
@@ -44,7 +44,7 @@
* var out = replaceBefore( 'Hello World!', 'XYZ', 'foo' );
* // returns 'Hello World!'
*/
-declare function replaceBefore( str: string, search: string, replacement: string ): string;
+declare function replaceBefore( str: string, search: string, replacement: string ): string; // tslint:disable-line:max-line-length
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
index 9acceb3e7856..f935b62d7b0f 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/types/test.ts
@@ -31,30 +31,30 @@ import replaceBefore = require( './index' );
// The compiler throws an error if the function is provided arguments having invalid types...
{
replaceBefore( true, 'd', 'foo' ); // $ExpectError
- replaceBefore( false, 'd' , 'foo'); // $ExpectError
- replaceBefore( 3, 'd' , 'foo'); // $ExpectError
- replaceBefore( [], 'd' , 'foo'); // $ExpectError
- replaceBefore( {}, 'd' , 'foo'); // $ExpectError
+ replaceBefore( false, 'd' , 'foo' ); // $ExpectError
+ replaceBefore( 3, 'd' , 'foo' ); // $ExpectError
+ replaceBefore( [], 'd' , 'foo' ); // $ExpectError
+ replaceBefore( {}, 'd' , 'foo' ); // $ExpectError
replaceBefore( ( x: number ): number => x, 'd', 'foo' ); // $ExpectError
replaceBefore( 'abc', true, 'foo' ); // $ExpectError
replaceBefore( 'abc', false, 'foo' ); // $ExpectError
- replaceBefore( 'abc', 5 , 'foo'); // $ExpectError
+ replaceBefore( 'abc', 5 , 'foo' ); // $ExpectError
replaceBefore( 'abc', [], 'foo' ); // $ExpectError
- replaceBefore( 'abc', {} , 'foo'); // $ExpectError
- replaceBefore( 'abc', ( x: number ): number => x , 'foo'); // $ExpectError
-
- replaceBefore( 'abc', 'd', true ); // $ExpectError
- replaceBefore( 'abc', 'd', false ); // $ExpectError
- replaceBefore( 'abc', 'd', 5 ); // $ExpectError
- replaceBefore( 'abc', 'd', [] ); // $ExpectError
- replaceBefore( 'abc', 'd', {} ); // $ExpectError
- replaceBefore( 'abc', 'd', ( x: number ): number => x ); // $ExpectError
+ replaceBefore( 'abc', {} , 'foo' ); // $ExpectError
+ replaceBefore( 'abc', ( x: number ): number => x , 'foo' ); // $ExpectError
+
+ replaceBefore( 'abc', 'd', true ); // $ExpectError
+ replaceBefore( 'abc', 'd', false ); // $ExpectError
+ replaceBefore( 'abc', 'd', 5 ); // $ExpectError
+ replaceBefore( 'abc', 'd', [] ); // $ExpectError
+ replaceBefore( 'abc', 'd', {} ); // $ExpectError
+ replaceBefore( 'abc', 'd', ( x: number ): number => x ); // $ExpectError
}
// The compiler throws an error if the function is provided insufficient arguments...
{
replaceBefore(); // $ExpectError
replaceBefore( 'abc' ); // $ExpectError
- replaceBefore( 'abc', 'd' ); // $ExpectError
+ replaceBefore( 'abc', 'd' ); // $ExpectError
}
From 0b06210dffa5e6913cc547117f66bb9f31405237 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 10:17:09 +0530
Subject: [PATCH 32/36] readme.md updated
---
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index afb941271c5f..46ff6503c5ff 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -209,4 +209,4 @@ seep
-
+
From 85b24ea4d88169c932555f4569ac6674396b0cd8 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 10:20:04 +0530
Subject: [PATCH 33/36] package.json updates
---
lib/node_modules/@stdlib/string/base/package.json | 4 +++-
lib/node_modules/@stdlib/string/base/replace-before/README.md | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/package.json b/lib/node_modules/@stdlib/string/base/package.json
index 8e752f5039d1..79cf5ea86268 100644
--- a/lib/node_modules/@stdlib/string/base/package.json
+++ b/lib/node_modules/@stdlib/string/base/package.json
@@ -56,6 +56,8 @@
"utility",
"utils",
"util",
- "base"
+ "base",
+ "replace"
]
}
+
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index 46ff6503c5ff..afb941271c5f 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -209,4 +209,4 @@ seep
-
+
From 321ef7bb65450127d19cd1f9851fe6334f26b5c6 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 10:27:51 +0530
Subject: [PATCH 34/36] repl.txt updates
---
.../@stdlib/string/base/replace-before/docs/repl.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
index 7607e09f097f..e9ce0d5ffc33 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
+++ b/lib/node_modules/@stdlib/string/base/replace-before/docs/repl.txt
@@ -1,6 +1,7 @@
{{alias}}( str, search, replacement )
- Replaces the substring before the first occurrence of a specified search string.
+ Replaces the substring before the first
+ occurrence of a specified search string.
Parameters
----------
From 2b47faa47effef68e34b6b38bb324305814798d1 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 10:39:55 +0530
Subject: [PATCH 35/36] readme.md updated
---
.../@stdlib/string/base/replace-before/README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/replace-before/README.md b/lib/node_modules/@stdlib/string/base/replace-before/README.md
index afb941271c5f..4a17ba216a54 100644
--- a/lib/node_modules/@stdlib/string/base/replace-before/README.md
+++ b/lib/node_modules/@stdlib/string/base/replace-before/README.md
@@ -77,18 +77,18 @@ out = replaceBefore( 'beep boop', 'o', 'bar' );
```javascript
-var substringBefore = require( '@stdlib/string/base/replace-before' );
+var replaceBefore = require( '@stdlib/string/base/replace-before' );
-var out = substringBefore( 'beep boop', 'p', 'see' );
+var out = replaceBefore( 'beep boop', 'p', 'see' );
// returns 'seep boop'
-out = substringBefore( 'Hello World!', 'xyz', 'foo' );
+out = replaceBefore( 'Hello World!', 'xyz', 'foo' );
// returns 'Hello World!'
-out = substringBefore( 'Hello World!', '', 'foo' );
+out = replaceBefore( 'Hello World!', '', 'foo' );
// returns 'Hello World!'
-out = substringBefore( '', 'xyz', 'foo');
+out = replaceBefore( '', 'xyz', 'foo');
// returns ''
```
From 8763a7d0ea138ba747abffa328a1972398404691 Mon Sep 17 00:00:00 2001
From: Harshita Kalani
Date: Fri, 24 Feb 2023 22:47:59 +0530
Subject: [PATCH 36/36] readme.md and package.json added to replace-after
---
.../string/base/replace-after/README.md | 249 ++++++++++++++++++
.../string/base/replace-after/package.json | 72 +++++
2 files changed, 321 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/replace-after/README.md
create mode 100644 lib/node_modules/@stdlib/string/base/replace-after/package.json
diff --git a/lib/node_modules/@stdlib/string/base/replace-after/README.md b/lib/node_modules/@stdlib/string/base/replace-after/README.md
new file mode 100644
index 000000000000..964431471486
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-after/README.md
@@ -0,0 +1,249 @@
+
+
+# replaceAfter
+
+> Replace the substring after the first occurrence of a specified search string.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var replaceAfter = require( '@stdlib/string/base/replace-after' );
+```
+
+#### replaceAfter( str, replacement, search\[, fromIndex] )
+
+Replaces the substring after the first occurrence of a specified search string.
+
+```javascript
+var str = 'beep boop';
+var replacement = 'foo';
+var out = replaceAfter( str, replacement, 'o' );
+// returns 'beep bofoo'
+
+out = replaceAfter( str, replacement, ' ' );
+// returns 'beep foo'
+```
+
+By default, the search starts at the beginning of the string. To start searching from a different index, provide a `fromIndex` argument:
+
+```javascript
+var str = 'boop baz boop';
+var replacement = 'foo';
+var out = replaceAfter( str, replacement, 'o', 3 );
+// returns 'boop baz bofoo'
+```
+
+
+
+
+
+
+
+
+
+## Notes
+
+- If a substring is not present in a provided string, the function returns an empty string.
+- If provided an empty substring, the function returns the input string.
+- If `fromIndex` is less than `0` or greater than `str.length`, the search starts at index `0` and `str.length`, respectively.
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var replaceAfter = require( '@stdlib/string/base/replace-after' );
+
+var str = 'To be, or not to be, that is the question.';
+var replacement = 'foo';
+var out = replaceAfter( str, replacement, ', ' );
+// returns 'To be, foo'
+
+out = replaceAfter( str, replacement, 'to be' );
+// returns 'To be, or not to befoo'
+
+out = replaceAfter( str, replacement, 'question.' );
+// returns 'To be, or not to be, that is the question.foo'
+
+out = replaceAfter( str, replacement, 'xyz' );
+// returns ''
+
+out = replaceAfter( str, replacement, '' );
+// returns 'foo'
+```
+
+
+
+
+
+
+
+* * *
+
+
+
+## CLI
+
+
+
+
+
+### Usage
+
+```text
+Usage: replace-after [options] --search= --replacement= []
+
+Options:
+
+ -h, --help Print this message.
+ -V, --version Print the package version.
+ --search string Search string.
+ --replacement string Replacement string.
+ --from-index int Start index. Default: 0.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
+```
+
+
+
+
+
+
+
+
+
+### Notes
+
+- If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
+
+ ```bash
+ # Not escaped...
+ $ echo -n $'foo\nbar\nbaz' | replace-after --search a --replacement b --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'foo\nbar\nbaz' | replace-after --search a --replacement b --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
+
+
+
+
+### Examples
+
+```bash
+$ replace-after abcdefg --search d --replacement pqr
+abcdpqr
+```
+
+To use as a [standard stream][standard-streams],
+
+```bash
+$ echo -n $'bar\nbaz' | replace-after --search b --replacement pqr
+bpqr
+bpqr
+```
+
+By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option.
+
+```bash
+$ echo -n 'bar\tbaz' | replace-after --search b --replacement pqr --split '\t'
+bpqr
+bpqr
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
+
+
+[@stdlib/string/substring-before]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-before
+
+[@stdlib/string/substring-before-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/substring-before-last
+
+[@stdlib/string/substring-after-last]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/replace-after-last
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/string/base/replace-after/package.json b/lib/node_modules/@stdlib/string/base/replace-after/package.json
new file mode 100644
index 000000000000..bb52f455d8ab
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/replace-after/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "@stdlib/string/base/replace-after",
+ "version": "0.0.0",
+ "description": "Replace the substring after the first occurrence of a specified search string.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "bin": {
+ "substring-after": "./bin/cli"
+ },
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdstring",
+ "utilities",
+ "utility",
+ "utils",
+ "util",
+ "string",
+ "str",
+ "check",
+ "search",
+ "replacement",
+ "substring",
+ "substr",
+ "after",
+ "match"
+ ]
+ }
+
\ No newline at end of file