Skip to content

Commit da5801e

Browse files
committed
Auto-generated commit
1 parent 976ecbc commit da5801e

File tree

9 files changed

+8
-112
lines changed

9 files changed

+8
-112
lines changed

.github/.keepalive

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-10-01T01:08:04.376Z

README.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -126,35 +126,12 @@ Options:
126126
127127
-h, --help Print this message.
128128
-V, --version Print the package version.
129-
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
130129
```
131130

132131
</section>
133132

134133
<!-- /.usage -->
135134

136-
<!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
137-
138-
<section class="notes">
139-
140-
### Notes
141-
142-
- If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
143-
144-
```bash
145-
# Not escaped...
146-
$ echo -n $' \nboop' | remove-utf8-bom --split /\r?\n/
147-
148-
# Escaped...
149-
$ echo -n $' \nboop' | remove-utf8-bom --split /\\r?\\n/
150-
```
151-
152-
- The implementation ignores trailing delimiters.
153-
154-
</section>
155-
156-
<!-- /.notes -->
157-
158135
<section class="examples">
159136

160137
### Examples
@@ -173,14 +150,6 @@ $ echo -n '\ufeffbeep' | remove-utf8-bom
173150
beep
174151
```
175152

176-
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.
177-
178-
```bash
179-
$ echo -n '\ufeffbeep\t\ufeffboop' | remove-utf8-bom --split '\t'
180-
beep
181-
boop
182-
```
183-
184153
</section>
185154

186155
<!-- /.examples -->
@@ -270,8 +239,6 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
270239

271240
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
272241

273-
[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
274-
275242
</section>
276243

277244
<!-- /.links -->

benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bench( pkg, function benchmark( b ) {
3838
for ( i = 0; i < b.iterations; i++ ) {
3939
str = '\ufeff' + fromCodePoint( i%126 ) + 'eep boop';
4040
out = removeUTF8BOM( str );
41-
if ( !isString( out ) ) {
41+
if ( typeof out !== 'string' ) {
4242
b.fail( 'should return a string' );
4343
}
4444
}

bin/cli

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ var readFileSync = require( '@stdlib/fs-read-file' ).sync;
2727
var CLI = require( '@stdlib/cli-ctor' );
2828
var stdin = require( '@stdlib/process-read-stdin' );
2929
var stdinStream = require( '@stdlib/streams-node-stdin' );
30-
var RE_EOL = require( '@stdlib/regexp-eol' ).REGEXP;
31-
var isRegExpString = require( '@stdlib/assert-is-regexp-string' );
32-
var reFromString = require( '@stdlib/utils-regexp-from-string' );
3330
var removeBOM = require( './../lib' );
3431

3532

@@ -42,7 +39,6 @@ var removeBOM = require( './../lib' );
4239
* @returns {void}
4340
*/
4441
function main() {
45-
var split;
4642
var flags;
4743
var args;
4844
var cli;
@@ -67,14 +63,6 @@ function main() {
6763

6864
// Check if we are receiving data from `stdin`...
6965
if ( !stdinStream.isTTY ) {
70-
if ( flags.split ) {
71-
if ( !isRegExpString( flags.split ) ) {
72-
flags.split = '/'+flags.split+'/';
73-
}
74-
split = reFromString( flags.split );
75-
} else {
76-
split = RE_EOL;
77-
}
7866
return stdin( onRead );
7967
}
8068
console.log( removeBOM( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -88,21 +76,11 @@ function main() {
8876
* @returns {void}
8977
*/
9078
function onRead( error, data ) {
91-
var lines;
92-
var i;
9379
if ( error ) {
9480
return cli.error( error );
9581
}
96-
97-
lines = data.toString().split( split );
98-
99-
// Remove any trailing separators (e.g., trailing newline)...
100-
if ( lines[ lines.length-1 ] === '' ) {
101-
lines.pop();
102-
}
103-
for ( i = 0; i < lines.length; i++ ) {
104-
console.log( removeBOM( lines[ i ] ) ); // eslint-disable-line no-console
105-
}
82+
data = data.toString();
83+
console.log( removeBOM( data ) ); // eslint-disable-line no-console
10684
}
10785
}
10886

docs/types/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import removeUTF8BOM = require( './index' );
2626
removeUTF8BOM( '\ufeffbeep' ); // $ExpectType string
2727
}
2828

29-
// The function does not compile if provided a value other than a string...
29+
// The compiler throws an error if the function is provided a value other than a string...
3030
{
3131
removeUTF8BOM( true ); // $ExpectError
3232
removeUTF8BOM( false ); // $ExpectError
@@ -38,7 +38,7 @@ import removeUTF8BOM = require( './index' );
3838
removeUTF8BOM( ( x: number ): number => x ); // $ExpectError
3939
}
4040

41-
// The function does not compile if provided insufficient arguments...
41+
// The compiler throws an error if the function is provided insufficient arguments...
4242
{
4343
removeUTF8BOM(); // $ExpectError
4444
}

docs/usage.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ Options:
55

66
-h, --help Print this message.
77
-V, --version Print the package version.
8-
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.

etc/cli_opts.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"string": [
3-
"split"
4-
],
2+
"string": [],
53
"boolean": [
64
"help",
75
"version"

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,12 @@
4040
"url": "https://github.com/stdlib-js/stdlib/issues"
4141
},
4242
"dependencies": {
43-
"@stdlib/assert-is-regexp-string": "^0.0.x",
4443
"@stdlib/assert-is-string": "^0.0.x",
4544
"@stdlib/cli-ctor": "^0.0.x",
4645
"@stdlib/fs-read-file": "^0.0.x",
4746
"@stdlib/process-read-stdin": "^0.0.x",
48-
"@stdlib/regexp-eol": "^0.0.x",
4947
"@stdlib/streams-node-stdin": "^0.0.x",
50-
"@stdlib/string-format": "^0.0.x",
51-
"@stdlib/utils-regexp-from-string": "^0.0.x"
48+
"@stdlib/string-format": "^0.0.x"
5249
},
5350
"devDependencies": {
5451
"@stdlib/assert-is-browser": "^0.0.x",

test/test.cli.js

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -188,50 +188,6 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
188188
}
189189
});
190190

191-
tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
192-
var cmd = [
193-
'printf \'\ufeffbeep\t\ufeffboop\'',
194-
'|',
195-
EXEC_PATH,
196-
fpath,
197-
'--split \'\t\''
198-
];
199-
200-
exec( cmd.join( ' ' ), done );
201-
202-
function done( error, stdout, stderr ) {
203-
if ( error ) {
204-
t.fail( error.message );
205-
} else {
206-
t.strictEqual( stdout.toString(), 'beep\nboop\n', 'expected value' );
207-
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
208-
}
209-
t.end();
210-
}
211-
});
212-
213-
tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (regexp)', opts, function test( t ) {
214-
var cmd = [
215-
'printf \'\ufeffbeep\t\ufeffboop\'',
216-
'|',
217-
EXEC_PATH,
218-
fpath,
219-
'--split=/\\\\t/'
220-
];
221-
222-
exec( cmd.join( ' ' ), done );
223-
224-
function done( error, stdout, stderr ) {
225-
if ( error ) {
226-
t.fail( error.message );
227-
} else {
228-
t.strictEqual( stdout.toString(), 'beep\nboop\n', 'expected value' );
229-
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
230-
}
231-
t.end();
232-
}
233-
});
234-
235191
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 ) {
236192
var script;
237193
var opts;

0 commit comments

Comments
 (0)