Skip to content

Commit 9a7c790

Browse files
committed
Update CLI flag name, code style + docs
1 parent d0bfd4e commit 9a7c790

File tree

13 files changed

+29
-27
lines changed

13 files changed

+29
-27
lines changed

lib/node_modules/@stdlib/string/substring-after-last/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ limitations under the License.
4040
var substringAfterLast = require( '@stdlib/string/substring-after-last' );
4141
```
4242

43-
#### substringAfterLast( str, search\[, fromIndex=+Infinity] )
43+
#### substringAfterLast( str, search\[, fromIndex] )
4444

4545
Returns the part of a string after the last occurrence of a specified substring.
4646

@@ -132,7 +132,7 @@ Options:
132132
-h, --help Print this message.
133133
-V, --version Print the package version.
134134
--search string Search string.
135-
--fromIndex int Backwards-search start index. Default: +Infinity.
135+
--from-index int Index at which to start the search.
136136
```
137137

138138
</section>

lib/node_modules/@stdlib/string/substring-after-last/bin/cli

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
var resolve = require( 'path' ).resolve;
2626
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
2727
var CLI = require( '@stdlib/cli/ctor' );
28-
var Number = require( '@stdlib/number/ctor' );
2928
var stdin = require( '@stdlib/process/read-stdin' );
3029
var stdinStream = require( '@stdlib/streams/node/stdin' );
3130
var reEOL = require( '@stdlib/regexp/eol' );
@@ -74,8 +73,8 @@ function main() {
7473
if ( !stdinStream.isTTY ) {
7574
return stdin( onRead );
7675
}
77-
if ( flags.fromIndex ) {
78-
console.log( substringAfterLast( str, flags.search, Number( flags.fromIndex ) ) ); // eslint-disable-line no-console, max-len
76+
if ( flags[ 'from-index' ] ) {
77+
console.log( substringAfterLast( str, flags.search, parseInt( flags[ 'from-index' ], 10 ) ) ); // eslint-disable-line no-console
7978
} else {
8079
console.log( substringAfterLast( str, flags.search ) ); // eslint-disable-line no-console
8180
}
@@ -89,15 +88,17 @@ function main() {
8988
* @returns {void}
9089
*/
9190
function onRead( error, data ) {
91+
var fromIndex;
9292
var lines;
9393
var i;
9494
if ( error ) {
9595
return cli.error( error );
9696
}
9797
lines = data.toString().split( reEOL.REGEXP );
98-
if ( flags.fromIndex ) {
98+
if ( flags[ 'from-index' ] ) {
99+
fromIndex = parseInt( flags[ 'from-index' ], 10 );
99100
for ( i = 0; i < lines.length; i++ ) {
100-
console.log( substringAfterLast( lines[ i ], flags.search, Number( flags.fromIndex ) ) ); // eslint-disable-line no-console, max-len
101+
console.log( substringAfterLast( lines[ i ], flags.search, fromIndex ) ); // eslint-disable-line no-console, max-len
101102
}
102103
} else {
103104
for ( i = 0; i < lines.length; i++ ) {

lib/node_modules/@stdlib/string/substring-after-last/docs/repl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
fromIndex: integer (optional)
1414
Index of last character to be considered beginning of a match.
15-
Default: `+Infinity`.
15+
Default: `str.length`.
1616

1717
Returns
1818
-------

lib/node_modules/@stdlib/string/substring-after-last/docs/types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @param str - input string
2727
* @param search - search value
28-
* @param fromIndex - index of last character to be considered beginning of a match (default: `+Infinity`)
28+
* @param fromIndex - index of last character to be considered beginning of a match (default: `str.length`)
2929
* @returns substring
3030
*
3131
* @example

lib/node_modules/@stdlib/string/substring-after-last/docs/usage.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Options:
66
-h, --help Print this message.
77
-V, --version Print the package version.
88
--search string Search string.
9-
--fromIndex int Backwards-search start index. Default: +Infinity.
9+
--from-index int Index at which to start the search.

lib/node_modules/@stdlib/string/substring-after-last/etc/cli_opts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"string": [
33
"search",
4-
"fromIndex"
4+
"from-index"
55
],
66
"boolean": [
77
"help",

lib/node_modules/@stdlib/string/substring-after-last/lib/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
3131
*
3232
* @param {string} str - input string
3333
* @param {string} search - search value
34-
* @param {integer} [fromIndex=+Infinity] - index of last character to be considered beginning of a match
34+
* @param {integer} [fromIndex=str.length] - index of last character to be considered beginning of a match
3535
* @throws {TypeError} first argument must be a string primitive
3636
* @throws {TypeError} second argument must be a string primitive
3737
* @throws {TypeError} third argument must be an integer primitive

lib/node_modules/@stdlib/string/substring-after-last/test/test.cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ tape( 'the command-line interface prints the part of a string after last ocurren
168168
var cmd = [
169169
EXEC_PATH,
170170
'-e',
171-
'"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=b\'; process.argv[ 3 ] = \'--fromIndex=3\'; process.argv[ 4 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
171+
'"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=b\'; process.argv[ 3 ] = \'--from-index=3\'; process.argv[ 4 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
172172
];
173173

174174
exec( cmd.join( ' ' ), done );
@@ -215,7 +215,7 @@ tape( 'the command-line interface supports use as a standard stream (custom star
215215
EXEC_PATH,
216216
fpath,
217217
'--search="e"',
218-
'--fromIndex=3'
218+
'--from-index=3'
219219
];
220220

221221
exec( cmd.join( ' ' ), done );

lib/node_modules/@stdlib/string/substring-after/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ limitations under the License.
4040
var substringAfter = require( '@stdlib/string/substring-after' );
4141
```
4242

43-
#### substringAfter( str, search\[, fromIndex=0] )
43+
#### substringAfter( str, search\[, fromIndex] )
4444

4545
Returns the part of a string after a specified substring.
4646

@@ -53,7 +53,7 @@ out = substringAfter( str, ' ' );
5353
// returns 'boop'
5454
```
5555

56-
By default, the search starts at the beginning of the string. To start the search at a different index, provide a `fromIndex` argument:
56+
By default, the search starts at the beginning of the string. To start searching from a different index, provide a `fromIndex` argument:
5757

5858
```javascript
5959
var str = 'boop baz boop';
@@ -73,7 +73,7 @@ var out = substringAfter( str, 'o', 3 );
7373

7474
- If a substring is not present in a provided string, the function returns an empty string.
7575
- If provided an empty substring, the function returns the input string.
76-
- If `fromIndex` is lower than `0` or greater than `str.length`, the search starts at index `0` and `str.length`, respectively.
76+
- If `fromIndex` is less than `0` or greater than `str.length`, the search starts at index `0` and `str.length`, respectively.
7777

7878
</section>
7979

@@ -133,7 +133,7 @@ Options:
133133
-h, --help Print this message.
134134
-V, --version Print the package version.
135135
--search string Search string.
136-
--fromIndex int Start index. Default: 0.
136+
--from-index int Start index. Default: 0.
137137
```
138138

139139
</section>

lib/node_modules/@stdlib/string/substring-after/bin/cli

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var resolve = require( 'path' ).resolve;
2626
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
2727
var CLI = require( '@stdlib/cli/ctor' );
2828
var stdin = require( '@stdlib/process/read-stdin' );
29-
var Number = require( '@stdlib/number/ctor' );
3029
var stdinStream = require( '@stdlib/streams/node/stdin' );
3130
var reEOL = require( '@stdlib/regexp/eol' );
3231
var substringAfter = require( './../lib' );
@@ -74,8 +73,8 @@ function main() {
7473
if ( !stdinStream.isTTY ) {
7574
return stdin( onRead );
7675
}
77-
if ( flags.fromIndex ) {
78-
console.log( substringAfter( str, flags.search, Number( flags.fromIndex ) ) ); // eslint-disable-line no-console, max-len
76+
if ( flags[ 'from-index' ] ) {
77+
console.log( substringAfter( str, flags.search, parseInt( flags[ 'from-index' ], 10 ) ) ); // eslint-disable-line no-console
7978
} else {
8079
console.log( substringAfter( str, flags.search ) ); // eslint-disable-line no-console
8180
}
@@ -89,15 +88,17 @@ function main() {
8988
* @returns {void}
9089
*/
9190
function onRead( error, data ) {
91+
var fromIndex;
9292
var lines;
9393
var i;
9494
if ( error ) {
9595
return cli.error( error );
9696
}
9797
lines = data.toString().split( reEOL.REGEXP );
98-
if ( flags.fromIndex ) {
98+
if ( flags[ 'from-index' ] ) {
99+
fromIndex = parseInt( flags[ 'from-index' ], 10 );
99100
for ( i = 0; i < lines.length; i++ ) {
100-
console.log( substringAfter( lines[ i ], flags.search, Number( flags.fromIndex ) ) ); // eslint-disable-line no-console, max-len
101+
console.log( substringAfter( lines[ i ], flags.search, fromIndex ) ); // eslint-disable-line no-console, max-len
101102
}
102103
} else {
103104
for ( i = 0; i < lines.length; i++ ) {

lib/node_modules/@stdlib/string/substring-after/docs/usage.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Options:
66
-h, --help Print this message.
77
-V, --version Print the package version.
88
--search string Search string.
9-
--fromIndex int Start index. Default: 0.
9+
--from-index int Start index. Default: 0.

lib/node_modules/@stdlib/string/substring-after/etc/cli_opts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"string": [
33
"search",
4-
"fromIndex"
4+
"from-index"
55
],
66
"boolean": [
77
"help",

lib/node_modules/@stdlib/string/substring-after/test/test.cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ tape( 'the command-line interface prints the part of a string after a specified
168168
var cmd = [
169169
EXEC_PATH,
170170
'-e',
171-
'"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=boop\'; process.argv[ 3 ] = \'--fromIndex=4\'; process.argv[ 4 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
171+
'"process.stdin.isTTY = true; process.argv[ 2 ] = \'--search=boop\'; process.argv[ 3 ] = \'--from-index=4\'; process.argv[ 4 ] = \'boopbeep\'; require( \''+fpath+'\' );"'
172172
];
173173

174174
exec( cmd.join( ' ' ), done );
@@ -215,7 +215,7 @@ tape( 'the command-line interface supports use as a standard stream (custom star
215215
EXEC_PATH,
216216
fpath,
217217
'--search=" "',
218-
'--fromIndex=6'
218+
'--from-index=6'
219219
];
220220

221221
exec( cmd.join( ' ' ), done );

0 commit comments

Comments
 (0)