Skip to content

Commit 30c03c6

Browse files
committed
Auto-generated commit
1 parent 60c4993 commit 30c03c6

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ npm install @stdlib/string-substring-after
5252
var substringAfter = require( '@stdlib/string-substring-after' );
5353
```
5454

55-
#### substringAfter( str, search\[, fromIndex=0] )
55+
#### substringAfter( str, search\[, fromIndex] )
5656

5757
Returns the part of a string after a specified substring.
5858

@@ -65,7 +65,7 @@ out = substringAfter( str, ' ' );
6565
// returns 'boop'
6666
```
6767

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

7070
```javascript
7171
var str = 'boop baz boop';
@@ -85,7 +85,7 @@ var out = substringAfter( str, 'o', 3 );
8585

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

9090
</section>
9191

@@ -155,7 +155,7 @@ Options:
155155
-h, --help Print this message.
156156
-V, --version Print the package version.
157157
--search string Search string.
158-
--fromIndex int Start index. Default: 0.
158+
--from-index int Start index. Default: 0.
159159
```
160160

161161
</section>

bin/cli

Lines changed: 6 additions & 5 deletions
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++ ) {

docs/usage.txt

Lines changed: 1 addition & 1 deletion
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.

etc/cli_opts.json

Lines changed: 1 addition & 1 deletion
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",

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"@stdlib/assert-is-string": "^0.0.x",
4545
"@stdlib/cli-ctor": "^0.0.x",
4646
"@stdlib/fs-read-file": "^0.0.x",
47-
"@stdlib/number-ctor": "^0.0.x",
4847
"@stdlib/process-read-stdin": "^0.0.x",
4948
"@stdlib/regexp-eol": "^0.0.x",
5049
"@stdlib/streams-node-stdin": "^0.0.x",

test/test.cli.js

Lines changed: 2 additions & 2 deletions
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)