diff --git a/README.md b/README.md
index e98ef386..ca6195cf 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,7 @@ Many of the assertion utilities have corresponding packages that test whether ar
- [`isArrayArray( value )`][@stdlib/assert/is-array-array]: test if a value is an array of arrays.
- [`isBooleanArray( value )`][@stdlib/assert/is-boolean-array]: test if a value is an array-like object of booleans.
+- [`isDateObjectArray( value )`][@stdlib/assert/is-date-object-array]: test if a value is an array-like object containing only Date objects.
- [`isFunctionArray( value )`][@stdlib/assert/is-function-array]: test if a value is an array-like object containing only functions.
- [`isNaNArray( value )`][@stdlib/assert/is-nan-array]: test if a value is an array-like object containing only NaN values.
- [`isNullArray( value )`][@stdlib/assert/is-null-array]: test if a value is an array-like object containing only null values.
@@ -401,6 +402,7 @@ The remaining namespace utilities are as follows:
- [`isComposite( value )`][@stdlib/assert/is-composite]: test if a value is a composite number.
- [`isConfigurablePropertyIn( value, property )`][@stdlib/assert/is-configurable-property-in]: test if an object's own or inherited property is configurable.
- [`isConfigurableProperty( value, property )`][@stdlib/assert/is-configurable-property]: test if an object's own property is configurable.
+- [`isCurrentYear( value )`][@stdlib/assert/is-current-year]: test if a value is the current year.
- [`isDataPropertyIn( value, property )`][@stdlib/assert/is-data-property-in]: test if an object's own or inherited property has a data descriptor.
- [`isDataProperty( value, property )`][@stdlib/assert/is-data-property]: test if an object's own property has a data descriptor.
- [`isDataView( value )`][@stdlib/assert/is-dataview]: test if a value is a DataView.
@@ -465,6 +467,7 @@ The remaining namespace utilities are as follows:
- [`isSameType( a, b )`][@stdlib/assert/is-same-type]: test if two arguments have the same type.
- [`isSameValueZero( a, b )`][@stdlib/assert/is-same-value-zero]: test if two arguments are the same value.
- [`isSameValue( a, b )`][@stdlib/assert/is-same-value]: test if two arguments are the same value.
+- [`isSemVer( value )`][@stdlib/assert/is-semver]: test if a value is a semantic version string.
- [`isStrictEqual( a, b )`][@stdlib/assert/is-strict-equal]: test if two arguments are strictly equal.
- [`isTruthy( value )`][@stdlib/assert/is-truthy]: test if a value is truthy.
- [`isUNCPath( value )`][@stdlib/assert/is-unc-path]: test if a value is a UNC path.
@@ -647,6 +650,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
[@stdlib/assert/is-configurable-property]: https://github.com/stdlib-js/assert/tree/main/is-configurable-property
+[@stdlib/assert/is-current-year]: https://github.com/stdlib-js/assert/tree/main/is-current-year
+
[@stdlib/assert/is-data-property-in]: https://github.com/stdlib-js/assert/tree/main/is-data-property-in
[@stdlib/assert/is-data-property]: https://github.com/stdlib-js/assert/tree/main/is-data-property
@@ -775,6 +780,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/assert/tree/main/is-same-value
+[@stdlib/assert/is-semver]: https://github.com/stdlib-js/assert/tree/main/is-semver
+
[@stdlib/assert/is-strict-equal]: https://github.com/stdlib-js/assert/tree/main/is-strict-equal
[@stdlib/assert/is-truthy]: https://github.com/stdlib-js/assert/tree/main/is-truthy
@@ -1069,6 +1076,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
[@stdlib/assert/is-boolean-array]: https://github.com/stdlib-js/assert/tree/main/is-boolean-array
+[@stdlib/assert/is-date-object-array]: https://github.com/stdlib-js/assert/tree/main/is-date-object-array
+
[@stdlib/assert/is-function-array]: https://github.com/stdlib-js/assert/tree/main/is-function-array
[@stdlib/assert/is-nan-array]: https://github.com/stdlib-js/assert/tree/main/is-nan-array
diff --git a/contains/lib/index.js b/contains/lib/index.js
index 3e38e81f..5fd5b826 100644
--- a/contains/lib/index.js
+++ b/contains/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var contains = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = contains;
+module.exports = main;
diff --git a/deep-equal/lib/index.js b/deep-equal/lib/index.js
index 9cc8dda6..b1bc8686 100644
--- a/deep-equal/lib/index.js
+++ b/deep-equal/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var deepEqual = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = deepEqual;
+module.exports = main;
diff --git a/deep-has-own-property/lib/index.js b/deep-has-own-property/lib/index.js
index 2e23d6fe..7742b0a8 100644
--- a/deep-has-own-property/lib/index.js
+++ b/deep-has-own-property/lib/index.js
@@ -62,15 +62,15 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var deepHasOwnProp = require( './main.js' );
+var main = require( './main.js' );
var factory = require( './factory.js' );
// MAIN //
-setReadOnly( deepHasOwnProp, 'factory', factory );
+setReadOnly( main, 'factory', factory );
// EXPORTS //
-module.exports = deepHasOwnProp;
+module.exports = main;
diff --git a/deep-has-property/lib/index.js b/deep-has-property/lib/index.js
index 2a758464..f846e2a0 100644
--- a/deep-has-property/lib/index.js
+++ b/deep-has-property/lib/index.js
@@ -68,15 +68,15 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var deepHasProp = require( './main.js' );
+var main = require( './main.js' );
var factory = require( './factory.js' );
// MAIN //
-setReadOnly( deepHasProp, 'factory', factory );
+setReadOnly( main, 'factory', factory );
// EXPORTS //
-module.exports = deepHasProp;
+module.exports = main;
diff --git a/has-arraybuffer-support/lib/index.js b/has-arraybuffer-support/lib/index.js
index 8458e593..eaea6be9 100644
--- a/has-arraybuffer-support/lib/index.js
+++ b/has-arraybuffer-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasArrayBufferSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasArrayBufferSupport;
+module.exports = main;
diff --git a/has-arrow-function-support/lib/index.js b/has-arrow-function-support/lib/index.js
index 6b3a0222..a3fb9739 100644
--- a/has-arrow-function-support/lib/index.js
+++ b/has-arrow-function-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasArrowFunctionSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasArrowFunctionSupport;
+module.exports = main;
diff --git a/has-async-await-support/lib/index.js b/has-async-await-support/lib/index.js
index a4cbc394..8d300336 100644
--- a/has-async-await-support/lib/index.js
+++ b/has-async-await-support/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var hasAsyncAwaitSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasAsyncAwaitSupport;
+module.exports = main;
diff --git a/has-async-iterator-symbol-support/lib/index.js b/has-async-iterator-symbol-support/lib/index.js
index 8522bb6c..17140849 100644
--- a/has-async-iterator-symbol-support/lib/index.js
+++ b/has-async-iterator-symbol-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasAsyncIteratorSymbolSupport = require( './main.js' ); // eslint-disable-line id-length
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasAsyncIteratorSymbolSupport;
+module.exports = main;
diff --git a/has-bigint-support/lib/index.js b/has-bigint-support/lib/index.js
index 48fab76a..5901caaf 100644
--- a/has-bigint-support/lib/index.js
+++ b/has-bigint-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasBigIntSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasBigIntSupport;
+module.exports = main;
diff --git a/has-class-support/lib/index.js b/has-class-support/lib/index.js
index 9f8b5e41..f5af820c 100644
--- a/has-class-support/lib/index.js
+++ b/has-class-support/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var hasClassSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasClassSupport;
+module.exports = main;
diff --git a/has-dataview-support/lib/index.js b/has-dataview-support/lib/index.js
index 39cc26f7..5f6f8b08 100644
--- a/has-dataview-support/lib/index.js
+++ b/has-dataview-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasDataViewSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasDataViewSupport;
+module.exports = main;
diff --git a/has-define-properties-support/lib/index.js b/has-define-properties-support/lib/index.js
index be0632a9..32bab612 100644
--- a/has-define-properties-support/lib/index.js
+++ b/has-define-properties-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasDefinePropertiesSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasDefinePropertiesSupport;
+module.exports = main;
diff --git a/has-define-property-support/lib/index.js b/has-define-property-support/lib/index.js
index 4d4f26d6..8b9e32b7 100644
--- a/has-define-property-support/lib/index.js
+++ b/has-define-property-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasDefinePropertySupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasDefinePropertySupport;
+module.exports = main;
diff --git a/has-function-name-support/lib/index.js b/has-function-name-support/lib/index.js
index 67bbcd61..13c0c312 100644
--- a/has-function-name-support/lib/index.js
+++ b/has-function-name-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasFunctionNameSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasFunctionNameSupport;
+module.exports = main;
diff --git a/has-generator-support/lib/index.js b/has-generator-support/lib/index.js
index 0981d875..89119439 100644
--- a/has-generator-support/lib/index.js
+++ b/has-generator-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasGeneratorSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasGeneratorSupport;
+module.exports = main;
diff --git a/has-globalthis-support/lib/index.js b/has-globalthis-support/lib/index.js
index 3b69d190..45a401e4 100644
--- a/has-globalthis-support/lib/index.js
+++ b/has-globalthis-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasGlobalThisSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasGlobalThisSupport;
+module.exports = main;
diff --git a/has-iterator-symbol-support/lib/index.js b/has-iterator-symbol-support/lib/index.js
index a203352c..f1cc01b2 100644
--- a/has-iterator-symbol-support/lib/index.js
+++ b/has-iterator-symbol-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasIteratorSymbolSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasIteratorSymbolSupport;
+module.exports = main;
diff --git a/has-map-support/lib/index.js b/has-map-support/lib/index.js
index fcfe1099..560eef61 100644
--- a/has-map-support/lib/index.js
+++ b/has-map-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasMapSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasMapSupport;
+module.exports = main;
diff --git a/has-node-buffer-support/lib/index.js b/has-node-buffer-support/lib/index.js
index da010dfd..e490de38 100644
--- a/has-node-buffer-support/lib/index.js
+++ b/has-node-buffer-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasNodeBufferSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasNodeBufferSupport;
+module.exports = main;
diff --git a/has-own-property/lib/index.js b/has-own-property/lib/index.js
index 65fe6a0b..578f35bb 100644
--- a/has-own-property/lib/index.js
+++ b/has-own-property/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var hasOwnProp = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasOwnProp;
+module.exports = main;
diff --git a/has-property/lib/index.js b/has-property/lib/index.js
index 0edfbe87..76514949 100644
--- a/has-property/lib/index.js
+++ b/has-property/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var hasProp = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasProp;
+module.exports = main;
diff --git a/has-proxy-support/lib/index.js b/has-proxy-support/lib/index.js
index 18abf893..d7f4d69e 100644
--- a/has-proxy-support/lib/index.js
+++ b/has-proxy-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasProxySupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasProxySupport;
+module.exports = main;
diff --git a/has-set-support/lib/index.js b/has-set-support/lib/index.js
index c5abfbc9..cb6de33e 100644
--- a/has-set-support/lib/index.js
+++ b/has-set-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasSetSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasSetSupport;
+module.exports = main;
diff --git a/has-sharedarraybuffer-support/lib/index.js b/has-sharedarraybuffer-support/lib/index.js
index 6f73e149..19faaac5 100644
--- a/has-sharedarraybuffer-support/lib/index.js
+++ b/has-sharedarraybuffer-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasSharedArrayBufferSupport = require( './main.js' ); // eslint-disable-line id-length
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasSharedArrayBufferSupport;
+module.exports = main;
diff --git a/has-symbol-support/lib/index.js b/has-symbol-support/lib/index.js
index f218afe8..567a7fa4 100644
--- a/has-symbol-support/lib/index.js
+++ b/has-symbol-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasSymbolSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasSymbolSupport;
+module.exports = main;
diff --git a/has-tostringtag-support/lib/index.js b/has-tostringtag-support/lib/index.js
index 80672c0d..21ce6290 100644
--- a/has-tostringtag-support/lib/index.js
+++ b/has-tostringtag-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasToStringTagSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasToStringTagSupport;
+module.exports = main;
diff --git a/has-wasm-support/lib/index.js b/has-wasm-support/lib/index.js
index ab2ff56d..91d64c10 100644
--- a/has-wasm-support/lib/index.js
+++ b/has-wasm-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasWebAssemblySupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasWebAssemblySupport;
+module.exports = main;
diff --git a/has-weakmap-support/lib/index.js b/has-weakmap-support/lib/index.js
index a1acf6a7..70de802a 100644
--- a/has-weakmap-support/lib/index.js
+++ b/has-weakmap-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasWeakMapSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasWeakMapSupport;
+module.exports = main;
diff --git a/has-weakset-support/lib/index.js b/has-weakset-support/lib/index.js
index d2382543..713f5857 100644
--- a/has-weakset-support/lib/index.js
+++ b/has-weakset-support/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var hasWeakSetSupport = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = hasWeakSetSupport;
+module.exports = main;
diff --git a/instance-of/lib/index.js b/instance-of/lib/index.js
index 34418df6..fac3a49b 100644
--- a/instance-of/lib/index.js
+++ b/instance-of/lib/index.js
@@ -44,9 +44,9 @@
// MODULES //
-var instanceOf = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = instanceOf;
+module.exports = main;
diff --git a/is-absolute-http-uri/docs/repl.txt b/is-absolute-http-uri/docs/repl.txt
index 29df275f..6b580965 100644
--- a/is-absolute-http-uri/docs/repl.txt
+++ b/is-absolute-http-uri/docs/repl.txt
@@ -1,3 +1,4 @@
+
{{alias}}( value )
Tests whether a value is an absolute HTTP(S) URI.
diff --git a/is-absolute-http-uri/lib/index.js b/is-absolute-http-uri/lib/index.js
index 082ed20c..87a0c0e8 100644
--- a/is-absolute-http-uri/lib/index.js
+++ b/is-absolute-http-uri/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isAbsoluteHttpURI = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAbsoluteHttpURI;
+module.exports = main;
diff --git a/is-absolute-path/README.md b/is-absolute-path/README.md
index c091832a..d91db25b 100644
--- a/is-absolute-path/README.md
+++ b/is-absolute-path/README.md
@@ -171,12 +171,35 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--platform name Platform: 'win32' or 'posix'.
+ --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/bar/baz\n./docs/repl.txt' | is-absolute-path --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'/foo/bar/baz\n./docs/repl.txt' | is-absolute-path --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -193,6 +216,14 @@ $ echo -n './docs/repl.txt' | is-absolute-path
false
```
+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 '/foo/bar/baz\t./docs/repl.txt' | is-absolute-path --platform=posix --split '\t'
+true
+false
+```
+
@@ -221,6 +252,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-relative-path]: https://github.com/stdlib-js/assert/tree/main/is-relative-path
diff --git a/is-absolute-path/bin/cli b/is-absolute-path/bin/cli
index f0c2fced..9850fac5 100755
--- a/is-absolute-path/bin/cli
+++ b/is-absolute-path/bin/cli
@@ -28,6 +28,8 @@ 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 isAbsolutePath = require( './../lib' );
@@ -40,6 +42,7 @@ var isAbsolutePath = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -72,6 +75,14 @@ function main() {
}
// 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( fun( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -90,7 +101,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( fun( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-absolute-path/docs/usage.txt b/is-absolute-path/docs/usage.txt
index c7893095..38547535 100644
--- a/is-absolute-path/docs/usage.txt
+++ b/is-absolute-path/docs/usage.txt
@@ -6,4 +6,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--platform name Platform: 'win32' or 'posix'.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-absolute-path/etc/cli_opts.json b/is-absolute-path/etc/cli_opts.json
index cd0c304c..7573cdbf 100644
--- a/is-absolute-path/etc/cli_opts.json
+++ b/is-absolute-path/etc/cli_opts.json
@@ -1,6 +1,7 @@
{
"string": [
- "platform"
+ "platform",
+ "split"
],
"boolean": [
"help",
diff --git a/is-absolute-path/test/test.cli.js b/is-absolute-path/test/test.cli.js
index db0676c4..03a36a06 100644
--- a/is-absolute-path/test/test.cli.js
+++ b/is-absolute-path/test/test.cli.js
@@ -183,6 +183,52 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'/foo/bar/baz\t./docs/repl.txt\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--platform=posix',
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'/foo/bar/baz\t./docs/repl.txt\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--platform=posix',
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-absolute-uri/docs/repl.txt b/is-absolute-uri/docs/repl.txt
index 27db8969..d9e60d32 100644
--- a/is-absolute-uri/docs/repl.txt
+++ b/is-absolute-uri/docs/repl.txt
@@ -1,3 +1,4 @@
+
{{alias}}( value )
Tests whether a value is an absolute URI.
diff --git a/is-absolute-uri/lib/index.js b/is-absolute-uri/lib/index.js
index b9a66f21..d493a5ce 100644
--- a/is-absolute-uri/lib/index.js
+++ b/is-absolute-uri/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isAbsoluteURI = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAbsoluteURI;
+module.exports = main;
diff --git a/is-accessor-property-in/lib/index.js b/is-accessor-property-in/lib/index.js
index 5f8f49df..eda604cb 100644
--- a/is-accessor-property-in/lib/index.js
+++ b/is-accessor-property-in/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isAccessorPropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAccessorPropertyIn;
+module.exports = main;
diff --git a/is-accessor-property/lib/index.js b/is-accessor-property/lib/index.js
index 71945ae4..3ff83277 100644
--- a/is-accessor-property/lib/index.js
+++ b/is-accessor-property/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isAccessorProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAccessorProperty;
+module.exports = main;
diff --git a/is-alphagram/README.md b/is-alphagram/README.md
index 61b4e8fd..0bfd912e 100644
--- a/is-alphagram/README.md
+++ b/is-alphagram/README.md
@@ -103,12 +103,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beep\nhello' | is-alphagram --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beep\nhello' | is-alphagram --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -125,6 +147,14 @@ $ echo -n 'hello' | is-alphagram
false
```
+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\thello' | is-alphagram --split '\t'
+true
+false
+```
+
@@ -155,6 +185,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-anagram]: https://github.com/stdlib-js/assert/tree/main/is-anagram
diff --git a/is-alphagram/bin/cli b/is-alphagram/bin/cli
index 9b19b28a..606ac347 100755
--- a/is-alphagram/bin/cli
+++ b/is-alphagram/bin/cli
@@ -28,6 +28,8 @@ 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 isAlphagram = require( './../lib' );
@@ -40,6 +42,7 @@ var isAlphagram = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isAlphagram( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isAlphagram( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-alphagram/docs/usage.txt b/is-alphagram/docs/usage.txt
index 26e7539b..594e18d2 100644
--- a/is-alphagram/docs/usage.txt
+++ b/is-alphagram/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-alphagram/etc/cli_opts.json b/is-alphagram/etc/cli_opts.json
index 92119c45..7c40f9a1 100644
--- a/is-alphagram/etc/cli_opts.json
+++ b/is-alphagram/etc/cli_opts.json
@@ -1,5 +1,7 @@
{
- "string": [],
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-alphagram/lib/index.js b/is-alphagram/lib/index.js
index d95eefbc..79fa9db5 100644
--- a/is-alphagram/lib/index.js
+++ b/is-alphagram/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isAlphagram = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAlphagram;
+module.exports = main;
diff --git a/is-alphagram/test/test.cli.js b/is-alphagram/test/test.cli.js
index 0c0b418d..1a565d35 100644
--- a/is-alphagram/test/test.cli.js
+++ b/is-alphagram/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\thello\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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\thello\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-alphanumeric/README.md b/is-alphanumeric/README.md
index 52a80f23..0ce8d171 100644
--- a/is-alphanumeric/README.md
+++ b/is-alphanumeric/README.md
@@ -97,12 +97,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beep\n01abc23456789' | is-alphanumeric --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beep\n01abc23456789' | is-alphanumeric --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -119,6 +141,14 @@ $ echo -n '0123456789' | is-alphanumeric
true
```
+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\t01abc23456789' | is-alphanumeric --split '\t'
+false
+true
+```
+
@@ -147,6 +177,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-digit-string]: https://github.com/stdlib-js/assert/tree/main/is-digit-string
diff --git a/is-alphanumeric/bin/cli b/is-alphanumeric/bin/cli
index ab321b90..3e4ab759 100755
--- a/is-alphanumeric/bin/cli
+++ b/is-alphanumeric/bin/cli
@@ -28,6 +28,8 @@ 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 isAlphaNumeric = require( './../lib' );
@@ -40,6 +42,7 @@ var isAlphaNumeric = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isAlphaNumeric( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isAlphaNumeric( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-alphanumeric/docs/usage.txt b/is-alphanumeric/docs/usage.txt
index 52af1456..ed59c473 100644
--- a/is-alphanumeric/docs/usage.txt
+++ b/is-alphanumeric/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-alphanumeric/etc/cli_opts.json b/is-alphanumeric/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-alphanumeric/etc/cli_opts.json
+++ b/is-alphanumeric/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-alphanumeric/lib/index.js b/is-alphanumeric/lib/index.js
index d1dd6110..619fe54c 100644
--- a/is-alphanumeric/lib/index.js
+++ b/is-alphanumeric/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isAlphaNumeric = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAlphaNumeric;
+module.exports = main;
diff --git a/is-alphanumeric/test/test.cli.js b/is-alphanumeric/test/test.cli.js
index 69964988..4c6c51d3 100644
--- a/is-alphanumeric/test/test.cli.js
+++ b/is-alphanumeric/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\t0123456789\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\t0123456789\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-anagram/README.md b/is-anagram/README.md
index c5d1dfcf..3a03acfb 100644
--- a/is-anagram/README.md
+++ b/is-anagram/README.md
@@ -116,12 +116,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--str string Comparison 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 $'baz\ntab' | is-anagram --str=zab --split /\r?\n/
+ # Escaped...
+ $ echo -n $'baz\ntab' | is-anagram --str=zab --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -139,6 +161,14 @@ true
false
```
+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 'tab\tbaz' | is-anagram --str=bat --split '\t'
+true
+false
+```
+
@@ -171,6 +201,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-alphagram]: https://github.com/stdlib-js/assert/tree/main/is-alphagram
diff --git a/is-anagram/bin/cli b/is-anagram/bin/cli
index a3fade8b..63d2b5a8 100755
--- a/is-anagram/bin/cli
+++ b/is-anagram/bin/cli
@@ -28,6 +28,8 @@ 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 isAnagram = require( './../lib' );
@@ -40,6 +42,7 @@ var isAnagram = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isAnagram( flags.str, args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isAnagram( flags.str, lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-anagram/docs/usage.txt b/is-anagram/docs/usage.txt
index 0cc6d3c2..81ee640a 100644
--- a/is-anagram/docs/usage.txt
+++ b/is-anagram/docs/usage.txt
@@ -6,3 +6,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--str string Comparison string.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-anagram/etc/cli_opts.json b/is-anagram/etc/cli_opts.json
index 4a8e7b5e..06541772 100644
--- a/is-anagram/etc/cli_opts.json
+++ b/is-anagram/etc/cli_opts.json
@@ -1,6 +1,7 @@
{
"string": [
- "str"
+ "str",
+ "split"
],
"boolean": [
"help",
diff --git a/is-anagram/lib/index.js b/is-anagram/lib/index.js
index df147445..2ee967e2 100644
--- a/is-anagram/lib/index.js
+++ b/is-anagram/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isAnagram = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isAnagram;
+module.exports = main;
diff --git a/is-anagram/test/test.cli.js b/is-anagram/test/test.cli.js
index b6d8e1e6..2bc9d849 100644
--- a/is-anagram/test/test.cli.js
+++ b/is-anagram/test/test.cli.js
@@ -185,6 +185,52 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'tab\tfoo\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--str=bat',
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse', '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 \'tab\tfoo\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--str=bat',
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse', '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;
diff --git a/is-array-array/lib/index.js b/is-array-array/lib/index.js
index 53856145..68cac54a 100644
--- a/is-array-array/lib/index.js
+++ b/is-array-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isArrayArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrayArray;
+module.exports = main;
diff --git a/is-array-length/lib/index.js b/is-array-length/lib/index.js
index 7b5fd2fb..1a8700a5 100644
--- a/is-array-length/lib/index.js
+++ b/is-array-length/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isArrayLength = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrayLength;
+module.exports = main;
diff --git a/is-array-like-object/lib/index.js b/is-array-like-object/lib/index.js
index 8211f884..bd56ad8e 100644
--- a/is-array-like-object/lib/index.js
+++ b/is-array-like-object/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isArrayLikeObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrayLikeObject;
+module.exports = main;
diff --git a/is-array-like/lib/index.js b/is-array-like/lib/index.js
index 640822af..436bedad 100644
--- a/is-array-like/lib/index.js
+++ b/is-array-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isArrayLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrayLike;
+module.exports = main;
diff --git a/is-array/lib/index.js b/is-array/lib/index.js
index 07f8f6f4..9d870788 100644
--- a/is-array/lib/index.js
+++ b/is-array/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArray;
+module.exports = main;
diff --git a/is-arraybuffer/lib/index.js b/is-arraybuffer/lib/index.js
index ed172ba9..6e56c414 100644
--- a/is-arraybuffer/lib/index.js
+++ b/is-arraybuffer/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var isArrayBuffer = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrayBuffer;
+module.exports = main;
diff --git a/is-arrow-function/lib/index.js b/is-arrow-function/lib/index.js
index 7543a4f0..ee109ec7 100644
--- a/is-arrow-function/lib/index.js
+++ b/is-arrow-function/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isArrowFunction = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isArrowFunction;
+module.exports = main;
diff --git a/is-ascii/README.md b/is-ascii/README.md
index b21f8534..efd87667 100644
--- a/is-ascii/README.md
+++ b/is-ascii/README.md
@@ -96,12 +96,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp\n123' | is-ascii --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp\n123' | is-ascii --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -118,6 +140,14 @@ $ echo -n 'beep' | is-ascii
true
```
+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\t123' | is-ascii --split '\t'
+true
+false
+```
+
@@ -148,6 +178,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-string]: https://github.com/stdlib-js/assert/tree/main/is-string
diff --git a/is-ascii/bin/cli b/is-ascii/bin/cli
index f21cd72a..f61deda6 100755
--- a/is-ascii/bin/cli
+++ b/is-ascii/bin/cli
@@ -28,6 +28,8 @@ 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 isASCII = require( './../lib' );
@@ -40,6 +42,7 @@ var isASCII = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isASCII( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isASCII( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-ascii/docs/usage.txt b/is-ascii/docs/usage.txt
index 13d156ea..545c38ff 100644
--- a/is-ascii/docs/usage.txt
+++ b/is-ascii/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-ascii/etc/cli_opts.json b/is-ascii/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-ascii/etc/cli_opts.json
+++ b/is-ascii/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-ascii/lib/index.js b/is-ascii/lib/index.js
index f08bb692..175d8acd 100644
--- a/is-ascii/lib/index.js
+++ b/is-ascii/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isASCII = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isASCII;
+module.exports = main;
diff --git a/is-ascii/test/test.cli.js b/is-ascii/test/test.cli.js
index 3c6588c6..f7d5622f 100644
--- a/is-ascii/test/test.cli.js
+++ b/is-ascii/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\t123\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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\t123\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-between-array/lib/index.js b/is-between-array/lib/index.js
index 6ca7e4d0..b0478a06 100644
--- a/is-between-array/lib/index.js
+++ b/is-between-array/lib/index.js
@@ -46,9 +46,9 @@
// MODULES //
-var isBetweenArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBetweenArray;
+module.exports = main;
diff --git a/is-between/lib/index.js b/is-between/lib/index.js
index 2536953e..2c72ff23 100644
--- a/is-between/lib/index.js
+++ b/is-between/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isBetween = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBetween;
+module.exports = main;
diff --git a/is-binary-string/README.md b/is-binary-string/README.md
index bfe42b27..5197121f 100644
--- a/is-binary-string/README.md
+++ b/is-binary-string/README.md
@@ -98,12 +98,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\n100001110' | is-binary-string --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\n100001110' | is-binary-string --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -120,6 +142,14 @@ $ echo -n '0110' | is-binary-string
true
```
+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 '0110\t1234' | is-binary-string --split '\t'
+true
+false
+```
+
@@ -148,6 +178,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-string]: https://github.com/stdlib-js/assert/tree/main/is-string
diff --git a/is-binary-string/bin/cli b/is-binary-string/bin/cli
index 36a395ca..6bf0ac6d 100755
--- a/is-binary-string/bin/cli
+++ b/is-binary-string/bin/cli
@@ -28,6 +28,8 @@ 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 isBinaryString = require( './../lib' );
@@ -40,6 +42,7 @@ var isBinaryString = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isBinaryString( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isBinaryString( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-binary-string/docs/usage.txt b/is-binary-string/docs/usage.txt
index 85c73b79..da4f8200 100644
--- a/is-binary-string/docs/usage.txt
+++ b/is-binary-string/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-binary-string/etc/cli_opts.json b/is-binary-string/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-binary-string/etc/cli_opts.json
+++ b/is-binary-string/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-binary-string/lib/index.js b/is-binary-string/lib/index.js
index fb767f78..16d4df01 100644
--- a/is-binary-string/lib/index.js
+++ b/is-binary-string/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isBinaryString = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBinaryString;
+module.exports = main;
diff --git a/is-binary-string/test/test.cli.js b/is-binary-string/test/test.cli.js
index f1bb20ff..314c0eea 100644
--- a/is-binary-string/test/test.cli.js
+++ b/is-binary-string/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'1234\t0110\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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 \'1234\t0110\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-blank-string/README.md b/is-blank-string/README.md
index 28e1462c..16e1ec02 100644
--- a/is-blank-string/README.md
+++ b/is-blank-string/README.md
@@ -98,12 +98,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'\nisMobile' | is-blank-string --split /\r?\n/
+ # Escaped...
+ $ echo -n $'\nisMobile' | is-blank-string --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -120,6 +142,14 @@ $ echo -n ' \t ' | is-blank-string
true
```
+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 '\t123' | is-blank-string --split '\t'
+true
+false
+```
+
@@ -140,6 +170,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-blank-string/bin/cli b/is-blank-string/bin/cli
index 747dfab6..ffa2135b 100755
--- a/is-blank-string/bin/cli
+++ b/is-blank-string/bin/cli
@@ -28,6 +28,8 @@ 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 isBlankString = require( './../lib' );
@@ -40,6 +42,7 @@ var isBlankString = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isBlankString( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isBlankString( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-blank-string/docs/usage.txt b/is-blank-string/docs/usage.txt
index 3003f2b2..7b37c742 100644
--- a/is-blank-string/docs/usage.txt
+++ b/is-blank-string/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-blank-string/etc/cli_opts.json b/is-blank-string/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-blank-string/etc/cli_opts.json
+++ b/is-blank-string/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-blank-string/lib/index.js b/is-blank-string/lib/index.js
index fd0b0b00..17694c0e 100644
--- a/is-blank-string/lib/index.js
+++ b/is-blank-string/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isBlankString = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBlankString;
+module.exports = main;
diff --git a/is-blank-string/test/test.cli.js b/is-blank-string/test/test.cli.js
index b7fcdddc..5f8817ee 100644
--- a/is-blank-string/test/test.cli.js
+++ b/is-blank-string/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'\tfoo\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'\tfoo\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-boolean/lib/index.js b/is-boolean/lib/index.js
index 2977ce54..ddcbec09 100644
--- a/is-boolean/lib/index.js
+++ b/is-boolean/lib/index.js
@@ -57,17 +57,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isBoolean = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isBoolean, 'isPrimitive', isPrimitive );
-setReadOnly( isBoolean, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isBoolean;
+module.exports = main;
diff --git a/is-boxed-primitive/lib/index.js b/is-boxed-primitive/lib/index.js
index c56178b2..25ecc407 100644
--- a/is-boxed-primitive/lib/index.js
+++ b/is-boxed-primitive/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var isBoxedPrimitive = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBoxedPrimitive;
+module.exports = main;
diff --git a/is-browser/lib/index.js b/is-browser/lib/index.js
index f5b1e3fd..7120e38e 100644
--- a/is-browser/lib/index.js
+++ b/is-browser/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isBrowser = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isBrowser();
+var bool = main();
// EXPORTS //
diff --git a/is-buffer/lib/index.js b/is-buffer/lib/index.js
index 325dbadb..97ab9c32 100644
--- a/is-buffer/lib/index.js
+++ b/is-buffer/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isBuffer = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isBuffer;
+module.exports = main;
diff --git a/is-capitalized/README.md b/is-capitalized/README.md
index 827cbd91..ab9f1b97 100644
--- a/is-capitalized/README.md
+++ b/is-capitalized/README.md
@@ -102,10 +102,32 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\nFoo Bar' | is-capitalized --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\nFoo Bar' | is-capitalized --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
@@ -126,6 +148,14 @@ $ echo -n 'boop' | is-capitalized
false
```
+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\tFoo' | is-capitalized --split '\t'
+false
+true
+```
+
@@ -152,6 +182,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-string]: https://github.com/stdlib-js/assert/tree/main/is-string
diff --git a/is-capitalized/bin/cli b/is-capitalized/bin/cli
index 092d180b..4c9a586d 100755
--- a/is-capitalized/bin/cli
+++ b/is-capitalized/bin/cli
@@ -28,6 +28,8 @@ 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 isCapitalized = require( './../lib' );
@@ -40,6 +42,7 @@ var isCapitalized = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isCapitalized( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isCapitalized( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-capitalized/docs/usage.txt b/is-capitalized/docs/usage.txt
index 1c23672c..38791cb5 100644
--- a/is-capitalized/docs/usage.txt
+++ b/is-capitalized/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-capitalized/etc/cli_opts.json b/is-capitalized/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-capitalized/etc/cli_opts.json
+++ b/is-capitalized/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-capitalized/lib/index.js b/is-capitalized/lib/index.js
index 1761d583..dbf28b6a 100644
--- a/is-capitalized/lib/index.js
+++ b/is-capitalized/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isCapitalized = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCapitalized;
+module.exports = main;
diff --git a/is-capitalized/test/test.cli.js b/is-capitalized/test/test.cli.js
index d16c185a..db04fa3b 100644
--- a/is-capitalized/test/test.cli.js
+++ b/is-capitalized/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\tFoo Bar\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\tFoo Bar\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-centrosymmetric-matrix/lib/index.js b/is-centrosymmetric-matrix/lib/index.js
index 423e184d..f79a101f 100644
--- a/is-centrosymmetric-matrix/lib/index.js
+++ b/is-centrosymmetric-matrix/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isCentrosymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCentrosymmetricMatrix;
+module.exports = main;
diff --git a/is-circular-array/lib/index.js b/is-circular-array/lib/index.js
index 0849fc43..85cfc2c8 100644
--- a/is-circular-array/lib/index.js
+++ b/is-circular-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isCircularArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCircularArray;
+module.exports = main;
diff --git a/is-circular-plain-object/lib/index.js b/is-circular-plain-object/lib/index.js
index 60837f7c..95c5f473 100644
--- a/is-circular-plain-object/lib/index.js
+++ b/is-circular-plain-object/lib/index.js
@@ -43,9 +43,9 @@
// MODULES //
-var isCircularPlainObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCircularPlainObject;
+module.exports = main;
diff --git a/is-circular/lib/index.js b/is-circular/lib/index.js
index 0c20f260..7cd704e3 100644
--- a/is-circular/lib/index.js
+++ b/is-circular/lib/index.js
@@ -43,9 +43,9 @@
// MODULES //
-var isCircular = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCircular;
+module.exports = main;
diff --git a/is-collection/lib/index.js b/is-collection/lib/index.js
index e156f384..8d756060 100644
--- a/is-collection/lib/index.js
+++ b/is-collection/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isCollection = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isCollection;
+module.exports = main;
diff --git a/is-complex-like/lib/index.js b/is-complex-like/lib/index.js
index bb4b8147..4e309ef1 100644
--- a/is-complex-like/lib/index.js
+++ b/is-complex-like/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isComplexLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isComplexLike;
+module.exports = main;
diff --git a/is-complex-typed-array-like/lib/index.js b/is-complex-typed-array-like/lib/index.js
index ba521158..beb4fc7a 100644
--- a/is-complex-typed-array-like/lib/index.js
+++ b/is-complex-typed-array-like/lib/index.js
@@ -43,9 +43,9 @@
// MODULES //
-var isComplexTypedArrayLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isComplexTypedArrayLike;
+module.exports = main;
diff --git a/is-complex-typed-array/lib/index.js b/is-complex-typed-array/lib/index.js
index 2c2df6cd..58a0d8f5 100644
--- a/is-complex-typed-array/lib/index.js
+++ b/is-complex-typed-array/lib/index.js
@@ -33,9 +33,9 @@
// MODULES //
-var isComplexTypedArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isComplexTypedArray;
+module.exports = main;
diff --git a/is-complex/lib/index.js b/is-complex/lib/index.js
index 87906ba6..4cb592a8 100644
--- a/is-complex/lib/index.js
+++ b/is-complex/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isComplex = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isComplex;
+module.exports = main;
diff --git a/is-composite/lib/index.js b/is-composite/lib/index.js
index 5e1801f3..3bfe0680 100644
--- a/is-composite/lib/index.js
+++ b/is-composite/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isComposite = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isComposite, 'isPrimitive', isPrimitive );
-setReadOnly( isComposite, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isComposite;
+module.exports = main;
diff --git a/is-configurable-property-in/lib/index.js b/is-configurable-property-in/lib/index.js
index 2c326d83..367e129d 100644
--- a/is-configurable-property-in/lib/index.js
+++ b/is-configurable-property-in/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isConfigurablePropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isConfigurablePropertyIn;
+module.exports = main;
diff --git a/is-configurable-property/lib/index.js b/is-configurable-property/lib/index.js
index 63a3412b..101385d6 100644
--- a/is-configurable-property/lib/index.js
+++ b/is-configurable-property/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isConfigurableProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isConfigurableProperty;
+module.exports = main;
diff --git a/is-cube-number/lib/index.js b/is-cube-number/lib/index.js
index 385ce49f..94fc6486 100644
--- a/is-cube-number/lib/index.js
+++ b/is-cube-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isCubeNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isCubeNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isCubeNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isCubeNumber;
+module.exports = main;
diff --git a/is-current-year/README.md b/is-current-year/README.md
index 9bd2580a..fb65d8fb 100644
--- a/is-current-year/README.md
+++ b/is-current-year/README.md
@@ -92,12 +92,35 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'1998\n1999' | is-current-year --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'1998\n1999' | is-current-year --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -114,6 +137,14 @@ $ echo -n 1914 | is-current-year
false
```
+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 '2001\t2002' | is-current-year --split '\t'
+false
+false
+```
+
@@ -136,6 +167,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-current-year/bin/cli b/is-current-year/bin/cli
index 6f963055..208c94f3 100755
--- a/is-current-year/bin/cli
+++ b/is-current-year/bin/cli
@@ -28,6 +28,8 @@ 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 isCurrentYear = require( './../lib' );
@@ -40,6 +42,7 @@ var isCurrentYear = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isCurrentYear( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isCurrentYear( parseFloat( lines[ i ] ) ) ); // eslint-disable-line no-console
}
diff --git a/is-current-year/docs/usage.txt b/is-current-year/docs/usage.txt
index ba2908ac..975707b4 100644
--- a/is-current-year/docs/usage.txt
+++ b/is-current-year/docs/usage.txt
@@ -5,3 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-current-year/etc/cli_opts.json b/is-current-year/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-current-year/etc/cli_opts.json
+++ b/is-current-year/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-current-year/test/test.cli.js b/is-current-year/test/test.cli.js
index 9ec5b540..0b64256f 100644
--- a/is-current-year/test/test.cli.js
+++ b/is-current-year/test/test.cli.js
@@ -193,6 +193,58 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var year = new Date().getFullYear();
+ var cmd = [
+ 'printf \'%d\t%d\t%d\'',
+ year-1,
+ year,
+ year+1,
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\nfalse\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 year = new Date().getFullYear();
+ var cmd = [
+ 'printf \'%d\t%d\t%d\'',
+ year-1,
+ year,
+ year+1,
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\nfalse\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;
diff --git a/is-data-property-in/lib/index.js b/is-data-property-in/lib/index.js
index ab3aa88f..55a5594c 100644
--- a/is-data-property-in/lib/index.js
+++ b/is-data-property-in/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isDataPropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isDataPropertyIn;
+module.exports = main;
diff --git a/is-data-property/lib/index.js b/is-data-property/lib/index.js
index 46fada10..deeaaf57 100644
--- a/is-data-property/lib/index.js
+++ b/is-data-property/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isDataProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isDataProperty;
+module.exports = main;
diff --git a/is-dataview/lib/index.js b/is-dataview/lib/index.js
index f4b0bb83..0928f556 100644
--- a/is-dataview/lib/index.js
+++ b/is-dataview/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isDataView = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isDataView;
+module.exports = main;
diff --git a/is-date-object/lib/index.js b/is-date-object/lib/index.js
index 81a4c3d5..fa7fb2f1 100644
--- a/is-date-object/lib/index.js
+++ b/is-date-object/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isDateObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isDateObject;
+module.exports = main;
diff --git a/is-digit-string/README.md b/is-digit-string/README.md
index 67511543..fcdcfcc8 100644
--- a/is-digit-string/README.md
+++ b/is-digit-string/README.md
@@ -96,12 +96,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\n0123456' | is-digit-string --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\n0123456' | is-digit-string --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -118,6 +140,14 @@ $ echo -n '0123456789' | is-digit-string
true
```
+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\t123' | is-digit-string --split '\t'
+false
+true
+```
+
@@ -147,6 +177,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-hex-string]: https://github.com/stdlib-js/assert/tree/main/is-hex-string
diff --git a/is-digit-string/bin/cli b/is-digit-string/bin/cli
index 4aa96bc0..594b799e 100755
--- a/is-digit-string/bin/cli
+++ b/is-digit-string/bin/cli
@@ -28,6 +28,8 @@ 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 isDigitString = require( './../lib' );
@@ -40,6 +42,7 @@ var isDigitString = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isDigitString( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isDigitString( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-digit-string/docs/usage.txt b/is-digit-string/docs/usage.txt
index c9bf73e1..f6e70503 100644
--- a/is-digit-string/docs/usage.txt
+++ b/is-digit-string/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-digit-string/etc/cli_opts.json b/is-digit-string/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-digit-string/etc/cli_opts.json
+++ b/is-digit-string/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-digit-string/lib/index.js b/is-digit-string/lib/index.js
index 5fd6f98f..b7cbb014 100644
--- a/is-digit-string/lib/index.js
+++ b/is-digit-string/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isDigitString = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isDigitString;
+module.exports = main;
diff --git a/is-digit-string/test/test.cli.js b/is-digit-string/test/test.cli.js
index 4d343ed0..8a11a60a 100644
--- a/is-digit-string/test/test.cli.js
+++ b/is-digit-string/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\t123\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\t123\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-docker/lib/index.js b/is-docker/lib/index.js
index 386539d6..591de0a4 100644
--- a/is-docker/lib/index.js
+++ b/is-docker/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isDocker = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isDocker();
+var bool = main();
// EXPORTS //
diff --git a/is-electron-main/lib/index.js b/is-electron-main/lib/index.js
index 4a70ccb7..b44ff273 100644
--- a/is-electron-main/lib/index.js
+++ b/is-electron-main/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isElectronMain = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isElectronMain();
+var bool = main();
// EXPORTS //
diff --git a/is-electron-renderer/lib/index.js b/is-electron-renderer/lib/index.js
index 0066af5a..e5665bd1 100644
--- a/is-electron-renderer/lib/index.js
+++ b/is-electron-renderer/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isElectronRenderer = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isElectronRenderer();
+var bool = main();
// EXPORTS //
diff --git a/is-electron/lib/index.js b/is-electron/lib/index.js
index ab8152b4..8c90be21 100644
--- a/is-electron/lib/index.js
+++ b/is-electron/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isElectron = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isElectron();
+var bool = main();
// EXPORTS //
diff --git a/is-email-address/README.md b/is-email-address/README.md
index b76e785a..6e4334bc 100644
--- a/is-email-address/README.md
+++ b/is-email-address/README.md
@@ -103,12 +103,35 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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@bar.com\nboop' | is-email --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'foo@bar.com\nboop' | is-email --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -125,6 +148,14 @@ $ echo -n 'beep@boop.com' | is-email
true
```
+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 'foo@bar.com\tbeep' | is-email --split '\t'
+true
+false
+```
+
@@ -149,6 +180,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-email-address/bin/cli b/is-email-address/bin/cli
index 235b9a4b..a3c4530e 100755
--- a/is-email-address/bin/cli
+++ b/is-email-address/bin/cli
@@ -28,6 +28,8 @@ 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 isEmailAddress = require( './../lib' );
@@ -40,6 +42,7 @@ var isEmailAddress = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isEmailAddress( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isEmailAddress( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-email-address/docs/usage.txt b/is-email-address/docs/usage.txt
index f222b97d..5356fe17 100644
--- a/is-email-address/docs/usage.txt
+++ b/is-email-address/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-email-address/etc/cli_opts.json b/is-email-address/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-email-address/etc/cli_opts.json
+++ b/is-email-address/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-email-address/lib/index.js b/is-email-address/lib/index.js
index c6045950..86b20683 100644
--- a/is-email-address/lib/index.js
+++ b/is-email-address/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isEmail = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEmail;
+module.exports = main;
diff --git a/is-email-address/test/test.cli.js b/is-email-address/test/test.cli.js
index 6c624049..afbe530f 100644
--- a/is-email-address/test/test.cli.js
+++ b/is-email-address/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'foo@bar.com\tbeepBoop\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'foo@bar.com\tbeepBoop\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-empty-array/lib/index.js b/is-empty-array/lib/index.js
index 1cc18842..2893c7df 100644
--- a/is-empty-array/lib/index.js
+++ b/is-empty-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isEmptyArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEmptyArray;
+module.exports = main;
diff --git a/is-empty-object/lib/index.js b/is-empty-object/lib/index.js
index 648cd737..4aeaecce 100644
--- a/is-empty-object/lib/index.js
+++ b/is-empty-object/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isEmptyObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEmptyObject;
+module.exports = main;
diff --git a/is-empty-string/lib/index.js b/is-empty-string/lib/index.js
index 4bd18d25..f413fd7f 100644
--- a/is-empty-string/lib/index.js
+++ b/is-empty-string/lib/index.js
@@ -57,17 +57,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isEmptyString = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isEmptyString, 'isPrimitive', isPrimitive );
-setReadOnly( isEmptyString, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isEmptyString;
+module.exports = main;
diff --git a/is-enumerable-property-in/lib/index.js b/is-enumerable-property-in/lib/index.js
index ed9813a5..44933dfa 100644
--- a/is-enumerable-property-in/lib/index.js
+++ b/is-enumerable-property-in/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isEnumerablePropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEnumerablePropertyIn;
+module.exports = main;
diff --git a/is-enumerable-property/lib/index.js b/is-enumerable-property/lib/index.js
index 6e38d721..fdcf913a 100644
--- a/is-enumerable-property/lib/index.js
+++ b/is-enumerable-property/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isEnumerableProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEnumerableProperty;
+module.exports = main;
diff --git a/is-error/lib/index.js b/is-error/lib/index.js
index 7a6f14aa..a904e953 100644
--- a/is-error/lib/index.js
+++ b/is-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isError;
+module.exports = main;
diff --git a/is-eval-error/lib/index.js b/is-eval-error/lib/index.js
index fd820002..056a6c92 100644
--- a/is-eval-error/lib/index.js
+++ b/is-eval-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isEvalError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isEvalError;
+module.exports = main;
diff --git a/is-even/lib/index.js b/is-even/lib/index.js
index f829cd31..627abe1b 100644
--- a/is-even/lib/index.js
+++ b/is-even/lib/index.js
@@ -68,17 +68,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isEven = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isEven, 'isPrimitive', isPrimitive );
-setReadOnly( isEven, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isEven;
+module.exports = main;
diff --git a/is-falsy/lib/index.js b/is-falsy/lib/index.js
index 9603753a..314a7c4f 100644
--- a/is-falsy/lib/index.js
+++ b/is-falsy/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isFalsy = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isFalsy;
+module.exports = main;
diff --git a/is-finite/lib/index.js b/is-finite/lib/index.js
index e3622f33..46fb8bdc 100644
--- a/is-finite/lib/index.js
+++ b/is-finite/lib/index.js
@@ -62,17 +62,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isFinite = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isFinite, 'isPrimitive', isPrimitive );
-setReadOnly( isFinite, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isFinite;
+module.exports = main;
diff --git a/is-function/lib/index.js b/is-function/lib/index.js
index e70e3eba..447c4d24 100644
--- a/is-function/lib/index.js
+++ b/is-function/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var isFunction = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isFunction;
+module.exports = main;
diff --git a/is-generator-object-like/lib/index.js b/is-generator-object-like/lib/index.js
index 03967d3b..140116db 100644
--- a/is-generator-object-like/lib/index.js
+++ b/is-generator-object-like/lib/index.js
@@ -40,9 +40,9 @@
// MODULES //
-var isGeneratorObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isGeneratorObject;
+module.exports = main;
diff --git a/is-generator-object/lib/index.js b/is-generator-object/lib/index.js
index 51d4cadc..595693c9 100644
--- a/is-generator-object/lib/index.js
+++ b/is-generator-object/lib/index.js
@@ -46,9 +46,9 @@
// MODULES //
-var isGeneratorObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isGeneratorObject;
+module.exports = main;
diff --git a/is-gzip-buffer/lib/index.js b/is-gzip-buffer/lib/index.js
index 193bdf67..07b6ef6b 100644
--- a/is-gzip-buffer/lib/index.js
+++ b/is-gzip-buffer/lib/index.js
@@ -44,9 +44,9 @@
// MODULES //
-var isgzipBuffer = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isgzipBuffer;
+module.exports = main;
diff --git a/is-hex-string/README.md b/is-hex-string/README.md
index 5f81ba58..2ad3abb4 100644
--- a/is-hex-string/README.md
+++ b/is-hex-string/README.md
@@ -97,12 +97,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'0xffffff\n0123456789abcdefABCDEF | is-hex-string --split /\r?\n/
+ # Escaped...
+ $ echo -n $'0xffffff\n0123456789abcdefABCDEF | is-hex-string --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -119,6 +141,14 @@ $ echo -n '0123456789abcdefABCDEF' | is-hex-string
true
```
+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 '0123456789abcdefABCDEF\t0xffffff' | is-hex-string --split '\t'
+true
+false
+```
+
@@ -147,6 +177,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-string]: https://github.com/stdlib-js/assert/tree/main/is-string
diff --git a/is-hex-string/bin/cli b/is-hex-string/bin/cli
index db8d28c4..fc4cfa37 100755
--- a/is-hex-string/bin/cli
+++ b/is-hex-string/bin/cli
@@ -28,6 +28,8 @@ 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 isHexString = require( './../lib' );
@@ -40,6 +42,7 @@ var isHexString = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isHexString( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isHexString( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-hex-string/docs/usage.txt b/is-hex-string/docs/usage.txt
index 36eba20e..5d24c631 100644
--- a/is-hex-string/docs/usage.txt
+++ b/is-hex-string/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-hex-string/etc/cli_opts.json b/is-hex-string/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-hex-string/etc/cli_opts.json
+++ b/is-hex-string/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-hex-string/lib/index.js b/is-hex-string/lib/index.js
index 39eaf34d..f9cc1c8e 100644
--- a/is-hex-string/lib/index.js
+++ b/is-hex-string/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isHexString = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isHexString;
+module.exports = main;
diff --git a/is-hex-string/test/test.cli.js b/is-hex-string/test/test.cli.js
index 69cc1771..b84480ea 100644
--- a/is-hex-string/test/test.cli.js
+++ b/is-hex-string/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'0123456789abcdefABCDEF\t0xffffff\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalseE\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 \'0123456789abcdefABCDEF\t0xffffff\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalseE\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;
diff --git a/is-infinite/lib/index.js b/is-infinite/lib/index.js
index 1897357d..fe341e5d 100644
--- a/is-infinite/lib/index.js
+++ b/is-infinite/lib/index.js
@@ -60,17 +60,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isInfinite = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isInfinite, 'isPrimitive', isPrimitive );
-setReadOnly( isInfinite, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isInfinite;
+module.exports = main;
diff --git a/is-inherited-property/lib/index.js b/is-inherited-property/lib/index.js
index c8d4be2d..9c3a8ca4 100644
--- a/is-inherited-property/lib/index.js
+++ b/is-inherited-property/lib/index.js
@@ -42,9 +42,9 @@
// MODULES //
-var isInheritedProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isInheritedProperty;
+module.exports = main;
diff --git a/is-integer/lib/index.js b/is-integer/lib/index.js
index d79282ed..9f9aadf3 100644
--- a/is-integer/lib/index.js
+++ b/is-integer/lib/index.js
@@ -62,17 +62,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isInteger;
+module.exports = main;
diff --git a/is-iterator-like/lib/index.js b/is-iterator-like/lib/index.js
index a3b39f63..8f1f7f69 100644
--- a/is-iterator-like/lib/index.js
+++ b/is-iterator-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isIterator = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isIterator;
+module.exports = main;
diff --git a/is-json/lib/index.js b/is-json/lib/index.js
index 7d0de77c..47f5b0a7 100644
--- a/is-json/lib/index.js
+++ b/is-json/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isJSON = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isJSON;
+module.exports = main;
diff --git a/is-leap-year/README.md b/is-leap-year/README.md
index e586f5f2..2fca7442 100644
--- a/is-leap-year/README.md
+++ b/is-leap-year/README.md
@@ -113,12 +113,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'1993\n1992' | is-leap-year --split /\r?\n/
+ # Escaped...
+ $ echo -n $'1993\n1992' | is-leap-year --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -138,6 +160,14 @@ $ echo -n 1992 | is-leap-year
true
```
+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 '1992\t1993' | is-leap-year --split '\t'
+true
+false
+```
+
@@ -166,6 +196,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-leap-year/bin/cli b/is-leap-year/bin/cli
index 2d2feeea..d3b0e3cd 100755
--- a/is-leap-year/bin/cli
+++ b/is-leap-year/bin/cli
@@ -28,6 +28,8 @@ 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 isLeapYear = require( './../lib' );
@@ -40,6 +42,7 @@ var isLeapYear = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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 );
}
if ( args.length ) {
@@ -86,7 +97,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isLeapYear( parseFloat( lines[ i ] ) ) ); // eslint-disable-line no-console
}
diff --git a/is-leap-year/docs/usage.txt b/is-leap-year/docs/usage.txt
index 733ed5b5..defdb8ac 100644
--- a/is-leap-year/docs/usage.txt
+++ b/is-leap-year/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-leap-year/etc/cli_opts.json b/is-leap-year/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-leap-year/etc/cli_opts.json
+++ b/is-leap-year/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-leap-year/lib/index.js b/is-leap-year/lib/index.js
index c48c6898..a1f2a4b7 100644
--- a/is-leap-year/lib/index.js
+++ b/is-leap-year/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isLeapYear = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isLeapYear;
+module.exports = main;
diff --git a/is-leap-year/test/test.cli.js b/is-leap-year/test/test.cli.js
index aa14d0a2..2bfcba13 100644
--- a/is-leap-year/test/test.cli.js
+++ b/is-leap-year/test/test.cli.js
@@ -211,6 +211,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'1992\t1993\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'1992\t1993\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-localhost/docs/repl.txt b/is-localhost/docs/repl.txt
index a6cc2784..95319b0c 100644
--- a/is-localhost/docs/repl.txt
+++ b/is-localhost/docs/repl.txt
@@ -1,3 +1,4 @@
+
{{alias}}( value )
Tests whether a value is a localhost hostname.
diff --git a/is-localhost/lib/index.js b/is-localhost/lib/index.js
index 2135a82d..a668a8ba 100644
--- a/is-localhost/lib/index.js
+++ b/is-localhost/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isLocalhost = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isLocalhost;
+module.exports = main;
diff --git a/is-lowercase/README.md b/is-lowercase/README.md
index 93453463..8f69c8ef 100644
--- a/is-lowercase/README.md
+++ b/is-lowercase/README.md
@@ -102,12 +102,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beep\nisMobile' | is-lowercase --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beep\nisMobile' | is-lowercase --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -124,6 +146,14 @@ $ echo -n 'boop' | is-lowercase
true
```
+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\tBaz' | is-lowercase --split '\t'
+true
+false
+```
+
@@ -153,6 +183,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-string]: https://github.com/stdlib-js/assert/tree/main/is-string
diff --git a/is-lowercase/bin/cli b/is-lowercase/bin/cli
index 719497a7..77df4d7b 100755
--- a/is-lowercase/bin/cli
+++ b/is-lowercase/bin/cli
@@ -28,6 +28,8 @@ 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 isLowercase = require( './../lib' );
@@ -40,6 +42,7 @@ var isLowercase = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isLowercase( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isLowercase( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-lowercase/docs/usage.txt b/is-lowercase/docs/usage.txt
index 99694ac6..bd3e7933 100644
--- a/is-lowercase/docs/usage.txt
+++ b/is-lowercase/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-lowercase/etc/cli_opts.json b/is-lowercase/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-lowercase/etc/cli_opts.json
+++ b/is-lowercase/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-lowercase/lib/index.js b/is-lowercase/lib/index.js
index f541b1cc..3e503c89 100644
--- a/is-lowercase/lib/index.js
+++ b/is-lowercase/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isLowercase = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isLowercase;
+module.exports = main;
diff --git a/is-lowercase/test/test.cli.js b/is-lowercase/test/test.cli.js
index 5aeefad2..cb6cebf4 100644
--- a/is-lowercase/test/test.cli.js
+++ b/is-lowercase/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\tisMobile\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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\tisMobile\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-matrix-like/lib/index.js b/is-matrix-like/lib/index.js
index 56f19c2b..c25d2cda 100644
--- a/is-matrix-like/lib/index.js
+++ b/is-matrix-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isMatrixLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isMatrixLike;
+module.exports = main;
diff --git a/is-method-in/lib/index.js b/is-method-in/lib/index.js
index 456d88ad..2808a9b4 100644
--- a/is-method-in/lib/index.js
+++ b/is-method-in/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isMethodIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isMethodIn;
+module.exports = main;
diff --git a/is-method/lib/index.js b/is-method/lib/index.js
index c46946c4..eb6abdbd 100644
--- a/is-method/lib/index.js
+++ b/is-method/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isMethod = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isMethod;
+module.exports = main;
diff --git a/is-mobile/lib/index.js b/is-mobile/lib/index.js
index d8901686..cff722a7 100644
--- a/is-mobile/lib/index.js
+++ b/is-mobile/lib/index.js
@@ -32,14 +32,14 @@
// MODULES //
-var isMobile = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var IS_MOBILE = isMobile();
+var bool = main();
// EXPORTS //
-module.exports = IS_MOBILE;
+module.exports = bool;
diff --git a/is-named-typed-tuple-like/lib/index.js b/is-named-typed-tuple-like/lib/index.js
index f2023556..46252960 100644
--- a/is-named-typed-tuple-like/lib/index.js
+++ b/is-named-typed-tuple-like/lib/index.js
@@ -40,9 +40,9 @@
// MODULES //
-var isNamedTypedTupleLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNamedTypedTupleLike;
+module.exports = main;
diff --git a/is-nan/lib/index.js b/is-nan/lib/index.js
index 204d926c..50ce9dbb 100644
--- a/is-nan/lib/index.js
+++ b/is-nan/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isnan = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isnan, 'isPrimitive', isPrimitive );
-setReadOnly( isnan, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isnan;
+module.exports = main;
diff --git a/is-native-function/lib/index.js b/is-native-function/lib/index.js
index b2d53417..6daf8c9d 100644
--- a/is-native-function/lib/index.js
+++ b/is-native-function/lib/index.js
@@ -39,9 +39,9 @@
// MODULES //
-var isNativeFunction = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNativeFunction;
+module.exports = main;
diff --git a/is-ndarray-like/lib/index.js b/is-ndarray-like/lib/index.js
index 1571eccf..f6d36396 100644
--- a/is-ndarray-like/lib/index.js
+++ b/is-ndarray-like/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isndarrayLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isndarrayLike;
+module.exports = main;
diff --git a/is-negative-integer/lib/index.js b/is-negative-integer/lib/index.js
index 24fa6f74..694a4d03 100644
--- a/is-negative-integer/lib/index.js
+++ b/is-negative-integer/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNegativeInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNegativeInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isNegativeInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNegativeInteger;
+module.exports = main;
diff --git a/is-negative-number/lib/index.js b/is-negative-number/lib/index.js
index adcff44d..87915362 100644
--- a/is-negative-number/lib/index.js
+++ b/is-negative-number/lib/index.js
@@ -65,17 +65,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNegativeNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNegativeNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isNegativeNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNegativeNumber;
+module.exports = main;
diff --git a/is-negative-zero/lib/index.js b/is-negative-zero/lib/index.js
index 49b44034..d4d3eb98 100644
--- a/is-negative-zero/lib/index.js
+++ b/is-negative-zero/lib/index.js
@@ -66,17 +66,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNegativeZero = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNegativeZero, 'isPrimitive', isPrimitive );
-setReadOnly( isNegativeZero, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNegativeZero;
+module.exports = main;
diff --git a/is-node-builtin/README.md b/is-node-builtin/README.md
index 0f2aff47..e71188ef 100644
--- a/is-node-builtin/README.md
+++ b/is-node-builtin/README.md
@@ -96,12 +96,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'crypto\nndarray' | is-note-builtin --split /\r?\n/
+ # Escaped...
+ $ echo -n $'crypto\nndarray' | is-note-builtin --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -120,6 +142,14 @@ true
false
```
+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 'crypto\tbaz' | is-node-builtin --split '\t'
+true
+false
+```
+
@@ -142,6 +172,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-node-builtin/bin/cli b/is-node-builtin/bin/cli
index 0df523e6..c64bb399 100755
--- a/is-node-builtin/bin/cli
+++ b/is-node-builtin/bin/cli
@@ -28,6 +28,8 @@ 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 isNodeBuiltin = require( './../lib' );
@@ -40,6 +42,7 @@ var isNodeBuiltin = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isNodeBuiltin( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isNodeBuiltin( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-node-builtin/docs/usage.txt b/is-node-builtin/docs/usage.txt
index 5ca60869..61cc5afb 100644
--- a/is-node-builtin/docs/usage.txt
+++ b/is-node-builtin/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-node-builtin/etc/cli_opts.json b/is-node-builtin/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-node-builtin/etc/cli_opts.json
+++ b/is-node-builtin/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-node-builtin/lib/index.js b/is-node-builtin/lib/index.js
index 6ebba908..b968ba7d 100644
--- a/is-node-builtin/lib/index.js
+++ b/is-node-builtin/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeBuiltin = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeBuiltin;
+module.exports = main;
diff --git a/is-node-builtin/test/test.cli.js b/is-node-builtin/test/test.cli.js
index 63d44391..cb3f1270 100644
--- a/is-node-builtin/test/test.cli.js
+++ b/is-node-builtin/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'crypto\tndarray\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'crypto\tndarray\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-node-duplex-stream-like/lib/index.js b/is-node-duplex-stream-like/lib/index.js
index 7638faa6..2970e540 100644
--- a/is-node-duplex-stream-like/lib/index.js
+++ b/is-node-duplex-stream-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeDuplexStreamLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeDuplexStreamLike;
+module.exports = main;
diff --git a/is-node-readable-stream-like/lib/index.js b/is-node-readable-stream-like/lib/index.js
index b1fa9b3f..294110da 100644
--- a/is-node-readable-stream-like/lib/index.js
+++ b/is-node-readable-stream-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeReadableStreamLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeReadableStreamLike;
+module.exports = main;
diff --git a/is-node-repl/lib/index.js b/is-node-repl/lib/index.js
index d59093d0..5d781fd1 100644
--- a/is-node-repl/lib/index.js
+++ b/is-node-repl/lib/index.js
@@ -32,9 +32,9 @@
// MODULES //
-var isNodeREPL = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeREPL;
+module.exports = main;
diff --git a/is-node-stream-like/lib/index.js b/is-node-stream-like/lib/index.js
index 2539b83d..ccfbd202 100644
--- a/is-node-stream-like/lib/index.js
+++ b/is-node-stream-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeStreamLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeStreamLike;
+module.exports = main;
diff --git a/is-node-transform-stream-like/lib/index.js b/is-node-transform-stream-like/lib/index.js
index b02fd08f..c5f7e09c 100644
--- a/is-node-transform-stream-like/lib/index.js
+++ b/is-node-transform-stream-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeTransformStreamLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeTransformStreamLike;
+module.exports = main;
diff --git a/is-node-writable-stream-like/lib/index.js b/is-node-writable-stream-like/lib/index.js
index 6be0f2e2..0d0536dd 100644
--- a/is-node-writable-stream-like/lib/index.js
+++ b/is-node-writable-stream-like/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNodeWritableStreamLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNodeWritableStreamLike;
+module.exports = main;
diff --git a/is-node/lib/index.js b/is-node/lib/index.js
index 9770f1c9..32e4ed03 100644
--- a/is-node/lib/index.js
+++ b/is-node/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isNode = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isNode();
+var bool = main();
// EXPORTS //
diff --git a/is-nonconfigurable-property-in/lib/index.js b/is-nonconfigurable-property-in/lib/index.js
index 198a9cee..3fe993b6 100644
--- a/is-nonconfigurable-property-in/lib/index.js
+++ b/is-nonconfigurable-property-in/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isNonConfigurablePropertyIn = require( './main.js' ); // eslint-disable-line id-length
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNonConfigurablePropertyIn;
+module.exports = main;
diff --git a/is-nonconfigurable-property/lib/index.js b/is-nonconfigurable-property/lib/index.js
index 0f09ab91..28bb46c0 100644
--- a/is-nonconfigurable-property/lib/index.js
+++ b/is-nonconfigurable-property/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isNonConfigurableProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNonConfigurableProperty;
+module.exports = main;
diff --git a/is-nonenumerable-property-in/lib/index.js b/is-nonenumerable-property-in/lib/index.js
index ba9731d3..14cf8bb0 100644
--- a/is-nonenumerable-property-in/lib/index.js
+++ b/is-nonenumerable-property-in/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isNonEnumerablePropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNonEnumerablePropertyIn;
+module.exports = main;
diff --git a/is-nonenumerable-property/lib/index.js b/is-nonenumerable-property/lib/index.js
index accffc1e..e98681f1 100644
--- a/is-nonenumerable-property/lib/index.js
+++ b/is-nonenumerable-property/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isNonEnumerableProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNonEnumerableProperty;
+module.exports = main;
diff --git a/is-nonnegative-integer/lib/index.js b/is-nonnegative-integer/lib/index.js
index 9f22521f..74d048ee 100644
--- a/is-nonnegative-integer/lib/index.js
+++ b/is-nonnegative-integer/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNonNegativeInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNonNegativeInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isNonNegativeInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNonNegativeInteger;
+module.exports = main;
diff --git a/is-nonnegative-number/lib/index.js b/is-nonnegative-number/lib/index.js
index 0346e26b..fadbee35 100644
--- a/is-nonnegative-number/lib/index.js
+++ b/is-nonnegative-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNonNegativeNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNonNegativeNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isNonNegativeNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNonNegativeNumber;
+module.exports = main;
diff --git a/is-nonpositive-integer/lib/index.js b/is-nonpositive-integer/lib/index.js
index d6ab9533..60683809 100644
--- a/is-nonpositive-integer/lib/index.js
+++ b/is-nonpositive-integer/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNonPositiveInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNonPositiveInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isNonPositiveInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNonPositiveInteger;
+module.exports = main;
diff --git a/is-nonpositive-number/lib/index.js b/is-nonpositive-number/lib/index.js
index 94a98185..97ec9cab 100644
--- a/is-nonpositive-number/lib/index.js
+++ b/is-nonpositive-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNonPositiveNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNonPositiveNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isNonPositiveNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNonPositiveNumber;
+module.exports = main;
diff --git a/is-nonsymmetric-matrix/lib/index.js b/is-nonsymmetric-matrix/lib/index.js
index 4fe2c559..48a6d29e 100644
--- a/is-nonsymmetric-matrix/lib/index.js
+++ b/is-nonsymmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isNonSymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNonSymmetricMatrix;
+module.exports = main;
diff --git a/is-null-array/lib/index.js b/is-null-array/lib/index.js
index 8c1a4d7c..8cf77e3d 100644
--- a/is-null-array/lib/index.js
+++ b/is-null-array/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isNullArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNullArray;
+module.exports = main;
diff --git a/is-null/lib/index.js b/is-null/lib/index.js
index cdbe3b82..143f0130 100644
--- a/is-null/lib/index.js
+++ b/is-null/lib/index.js
@@ -34,9 +34,9 @@
// MODULES //
-var isNull = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNull;
+module.exports = main;
diff --git a/is-number/lib/index.js b/is-number/lib/index.js
index bbea7253..da23b53d 100644
--- a/is-number/lib/index.js
+++ b/is-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isNumber;
+module.exports = main;
diff --git a/is-numeric-array/lib/index.js b/is-numeric-array/lib/index.js
index 96085efb..e6d3df75 100644
--- a/is-numeric-array/lib/index.js
+++ b/is-numeric-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isNumericArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isNumericArray;
+module.exports = main;
diff --git a/is-object-array/lib/index.js b/is-object-array/lib/index.js
index b2f97038..bb0d23de 100644
--- a/is-object-array/lib/index.js
+++ b/is-object-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isObjectArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isObjectArray;
+module.exports = main;
diff --git a/is-object-like/lib/index.js b/is-object-like/lib/index.js
index 2d588a46..0869b1c8 100644
--- a/is-object-like/lib/index.js
+++ b/is-object-like/lib/index.js
@@ -49,19 +49,19 @@
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
var arrayfun = require( './../../tools/array-function' );
-var isObjectLike = require( './main.js' );
+var main = require( './main.js' );
// VARIABLES //
-var isObjectLikeArray = arrayfun( isObjectLike );
+var isObjectLikeArray = arrayfun( main );
// MAIN //
-setReadOnly( isObjectLike, 'isObjectLikeArray', isObjectLikeArray );
+setReadOnly( main, 'isObjectLikeArray', isObjectLikeArray );
// EXPORTS //
-module.exports = isObjectLike;
+module.exports = main;
diff --git a/is-object/lib/index.js b/is-object/lib/index.js
index 94b0d36f..5ae4ef01 100644
--- a/is-object/lib/index.js
+++ b/is-object/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isObject;
+module.exports = main;
diff --git a/is-odd/lib/index.js b/is-odd/lib/index.js
index eb21b207..040498c6 100644
--- a/is-odd/lib/index.js
+++ b/is-odd/lib/index.js
@@ -66,17 +66,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isOdd = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isOdd, 'isPrimitive', isPrimitive );
-setReadOnly( isOdd, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isOdd;
+module.exports = main;
diff --git a/is-persymmetric-matrix/lib/index.js b/is-persymmetric-matrix/lib/index.js
index 28f2574f..f5a117e8 100644
--- a/is-persymmetric-matrix/lib/index.js
+++ b/is-persymmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isPersymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPersymmetricMatrix;
+module.exports = main;
diff --git a/is-plain-object-array/lib/index.js b/is-plain-object-array/lib/index.js
index 613decad..f264ee7b 100644
--- a/is-plain-object-array/lib/index.js
+++ b/is-plain-object-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isPlainObjectArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPlainObjectArray;
+module.exports = main;
diff --git a/is-plain-object/lib/index.js b/is-plain-object/lib/index.js
index 2bfbf22e..86dce349 100644
--- a/is-plain-object/lib/index.js
+++ b/is-plain-object/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isPlainObject = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPlainObject;
+module.exports = main;
diff --git a/is-positive-integer/lib/index.js b/is-positive-integer/lib/index.js
index 68e9cb24..8239ecfd 100644
--- a/is-positive-integer/lib/index.js
+++ b/is-positive-integer/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isPositiveInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isPositiveInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isPositiveInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isPositiveInteger;
+module.exports = main;
diff --git a/is-positive-number/lib/index.js b/is-positive-number/lib/index.js
index 9b2f5c65..8c14ea97 100644
--- a/is-positive-number/lib/index.js
+++ b/is-positive-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isPositiveNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isPositiveNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isPositiveNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isPositiveNumber;
+module.exports = main;
diff --git a/is-positive-zero/lib/index.js b/is-positive-zero/lib/index.js
index bf70538f..adb501dd 100644
--- a/is-positive-zero/lib/index.js
+++ b/is-positive-zero/lib/index.js
@@ -66,17 +66,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isPositiveZero = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isPositiveZero, 'isPrimitive', isPrimitive );
-setReadOnly( isPositiveZero, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isPositiveZero;
+module.exports = main;
diff --git a/is-prime/lib/index.js b/is-prime/lib/index.js
index db838011..a02838f6 100644
--- a/is-prime/lib/index.js
+++ b/is-prime/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isPrime = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isPrime, 'isPrimitive', isPrimitive );
-setReadOnly( isPrime, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isPrime;
+module.exports = main;
diff --git a/is-primitive-array/lib/index.js b/is-primitive-array/lib/index.js
index 6fc693af..55f541ec 100644
--- a/is-primitive-array/lib/index.js
+++ b/is-primitive-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isPrimitiveArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPrimitiveArray;
+module.exports = main;
diff --git a/is-primitive/lib/index.js b/is-primitive/lib/index.js
index 378be2ff..4487c426 100644
--- a/is-primitive/lib/index.js
+++ b/is-primitive/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isPrimitive = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPrimitive;
+module.exports = main;
diff --git a/is-prng-like/lib/index.js b/is-prng-like/lib/index.js
index 6cfb9087..97a7fb13 100644
--- a/is-prng-like/lib/index.js
+++ b/is-prng-like/lib/index.js
@@ -36,9 +36,9 @@
// MODULES //
-var isPRNGLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPRNGLike;
+module.exports = main;
diff --git a/is-probability/lib/index.js b/is-probability/lib/index.js
index 687fa3fe..c55eef30 100644
--- a/is-probability/lib/index.js
+++ b/is-probability/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isProbability = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isProbability, 'isPrimitive', isPrimitive );
-setReadOnly( isProbability, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isProbability;
+module.exports = main;
diff --git a/is-property-key/docs/repl.txt b/is-property-key/docs/repl.txt
index fbbf63ad..15d5e0e3 100644
--- a/is-property-key/docs/repl.txt
+++ b/is-property-key/docs/repl.txt
@@ -1,3 +1,4 @@
+
{{alias}}( value )
Tests whether a value is a property key.
diff --git a/is-property-key/lib/index.js b/is-property-key/lib/index.js
index 87d5797a..2207f9b8 100644
--- a/is-property-key/lib/index.js
+++ b/is-property-key/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isPropertyKey = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPropertyKey;
+module.exports = main;
diff --git a/is-prototype-of/lib/index.js b/is-prototype-of/lib/index.js
index aa730ed5..23d586e9 100644
--- a/is-prototype-of/lib/index.js
+++ b/is-prototype-of/lib/index.js
@@ -44,9 +44,9 @@
// MODULES //
-var isPrototypeOf = require( './main.js' ); // eslint-disable-line stdlib/no-redeclare
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isPrototypeOf;
+module.exports = main;
diff --git a/is-range-error/lib/index.js b/is-range-error/lib/index.js
index 896c6162..755500eb 100644
--- a/is-range-error/lib/index.js
+++ b/is-range-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isRangeError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isRangeError;
+module.exports = main;
diff --git a/is-read-only-property-in/lib/index.js b/is-read-only-property-in/lib/index.js
index a4252217..d95d58d6 100644
--- a/is-read-only-property-in/lib/index.js
+++ b/is-read-only-property-in/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isReadOnlyPropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadOnlyPropertyIn;
+module.exports = main;
diff --git a/is-read-only-property/lib/index.js b/is-read-only-property/lib/index.js
index 8fadd375..ec45951b 100644
--- a/is-read-only-property/lib/index.js
+++ b/is-read-only-property/lib/index.js
@@ -47,9 +47,9 @@
// MODULES //
-var isReadOnlyProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadOnlyProperty;
+module.exports = main;
diff --git a/is-read-write-property-in/lib/index.js b/is-read-write-property-in/lib/index.js
index 931d691d..60f0fdf3 100644
--- a/is-read-write-property-in/lib/index.js
+++ b/is-read-write-property-in/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isReadWritePropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadWritePropertyIn;
+module.exports = main;
diff --git a/is-read-write-property/lib/index.js b/is-read-write-property/lib/index.js
index 57b5c855..091ceca9 100644
--- a/is-read-write-property/lib/index.js
+++ b/is-read-write-property/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isReadWriteProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadWriteProperty;
+module.exports = main;
diff --git a/is-readable-property-in/lib/index.js b/is-readable-property-in/lib/index.js
index 198f7d12..cf073cd5 100644
--- a/is-readable-property-in/lib/index.js
+++ b/is-readable-property-in/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isReadablePropertyIn = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadablePropertyIn;
+module.exports = main;
diff --git a/is-readable-property/lib/index.js b/is-readable-property/lib/index.js
index e12e54ba..4058fb8d 100644
--- a/is-readable-property/lib/index.js
+++ b/is-readable-property/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isReadableProperty = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReadableProperty;
+module.exports = main;
diff --git a/is-reference-error/lib/index.js b/is-reference-error/lib/index.js
index 0d72dd6a..823b41f2 100644
--- a/is-reference-error/lib/index.js
+++ b/is-reference-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isReferenceError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isReferenceError;
+module.exports = main;
diff --git a/is-regexp-string/README.md b/is-regexp-string/README.md
index 1db08514..68d84bff 100644
--- a/is-regexp-string/README.md
+++ b/is-regexp-string/README.md
@@ -97,12 +97,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\n/beep/' | is-regexp-string --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\n/beep/' | is-regexp-string --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -119,6 +141,14 @@ $ echo -n '/beep/' | is-regexp-string
true
```
+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\t/boop/' | is-regexp-string --split '\t'
+false
+true
+```
+
@@ -147,6 +177,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-regexp]: https://github.com/stdlib-js/assert/tree/main/is-regexp
diff --git a/is-regexp-string/bin/cli b/is-regexp-string/bin/cli
index be3e5e8e..b3248f92 100755
--- a/is-regexp-string/bin/cli
+++ b/is-regexp-string/bin/cli
@@ -28,6 +28,7 @@ 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 reFromString = require( '@stdlib/utils/regexp-from-string' );
var isRegExpString = require( './../lib' );
@@ -40,6 +41,7 @@ var isRegExpString = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +66,14 @@ function main() {
// 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( isRegExpString( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +92,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isRegExpString( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-regexp-string/docs/usage.txt b/is-regexp-string/docs/usage.txt
index 0f84b25d..c0b37120 100644
--- a/is-regexp-string/docs/usage.txt
+++ b/is-regexp-string/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-regexp-string/etc/cli_opts.json b/is-regexp-string/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-regexp-string/etc/cli_opts.json
+++ b/is-regexp-string/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-regexp-string/lib/index.js b/is-regexp-string/lib/index.js
index 7f28f010..cb8f66a6 100644
--- a/is-regexp-string/lib/index.js
+++ b/is-regexp-string/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isRegExpString = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isRegExpString;
+module.exports = main;
diff --git a/is-regexp-string/test/test.cli.js b/is-regexp-string/test/test.cli.js
index c0c3e037..8e52c412 100644
--- a/is-regexp-string/test/test.cli.js
+++ b/is-regexp-string/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\t/baz/\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\t/baz/\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-regexp/lib/index.js b/is-regexp/lib/index.js
index 895473c0..ce7d7f97 100644
--- a/is-regexp/lib/index.js
+++ b/is-regexp/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isRegExp = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isRegExp;
+module.exports = main;
diff --git a/is-relative-path/README.md b/is-relative-path/README.md
index 55601088..27c51308 100644
--- a/is-relative-path/README.md
+++ b/is-relative-path/README.md
@@ -177,12 +177,35 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--platform name Platform: 'win32' or 'posix'.
+ --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/bar/baz\n./docs/repl.txt' | is-relative-path --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $'/foo/bar/baz\n./docs/repl.txt' | is-relative-path --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -199,6 +222,14 @@ $ echo -n './docs/repl.txt' | is-relative-path
true
```
+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 '/foo/bar/baz\t./docs/repl.txt' | is-relative-path --platform=posix --split '\t'
+false
+true
+```
+
@@ -227,6 +258,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-absolute-path]: https://github.com/stdlib-js/assert/tree/main/is-absolute-path
diff --git a/is-relative-path/bin/cli b/is-relative-path/bin/cli
index 5080e165..ca325dbb 100755
--- a/is-relative-path/bin/cli
+++ b/is-relative-path/bin/cli
@@ -28,6 +28,8 @@ 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 isRelativePath = require( './../lib' );
@@ -40,6 +42,7 @@ var isRelativePath = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -72,6 +75,14 @@ function main() {
}
// 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( fun( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -90,7 +101,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( fun( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-relative-path/docs/usage.txt b/is-relative-path/docs/usage.txt
index e9fc4704..09a77e40 100644
--- a/is-relative-path/docs/usage.txt
+++ b/is-relative-path/docs/usage.txt
@@ -6,4 +6,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
--platform name Platform: 'win32' or 'posix'.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-relative-path/etc/cli_opts.json b/is-relative-path/etc/cli_opts.json
index cd0c304c..7573cdbf 100644
--- a/is-relative-path/etc/cli_opts.json
+++ b/is-relative-path/etc/cli_opts.json
@@ -1,6 +1,7 @@
{
"string": [
- "platform"
+ "platform",
+ "split"
],
"boolean": [
"help",
diff --git a/is-relative-path/test/test.cli.js b/is-relative-path/test/test.cli.js
index d256474a..2aad75c8 100644
--- a/is-relative-path/test/test.cli.js
+++ b/is-relative-path/test/test.cli.js
@@ -183,6 +183,52 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'/foo/bar/baz\t./docs/repl.txt\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--platform=posix',
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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 \'/foo/bar/baz\t./docs/repl.txt\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--platform=posix',
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-relative-uri/docs/repl.txt b/is-relative-uri/docs/repl.txt
index be407ddf..ad012c45 100644
--- a/is-relative-uri/docs/repl.txt
+++ b/is-relative-uri/docs/repl.txt
@@ -1,3 +1,4 @@
+
{{alias}}( value )
Tests whether a value is a relative URI.
diff --git a/is-relative-uri/lib/index.js b/is-relative-uri/lib/index.js
index 92bb9f7b..81ba3842 100644
--- a/is-relative-uri/lib/index.js
+++ b/is-relative-uri/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isRelativeURI = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isRelativeURI;
+module.exports = main;
diff --git a/is-safe-integer/lib/index.js b/is-safe-integer/lib/index.js
index cef72ce8..7e4ac41b 100644
--- a/is-safe-integer/lib/index.js
+++ b/is-safe-integer/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isSafeInteger = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isSafeInteger, 'isPrimitive', isPrimitive );
-setReadOnly( isSafeInteger, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isSafeInteger;
+module.exports = main;
diff --git a/is-same-native-class/lib/index.js b/is-same-native-class/lib/index.js
index 5a73189d..bdb2cd0b 100644
--- a/is-same-native-class/lib/index.js
+++ b/is-same-native-class/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isSameNativeClass = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSameNativeClass;
+module.exports = main;
diff --git a/is-same-type/lib/index.js b/is-same-type/lib/index.js
index 6198f967..7ae88f1d 100644
--- a/is-same-type/lib/index.js
+++ b/is-same-type/lib/index.js
@@ -44,9 +44,9 @@
// MODULES //
-var isSameType = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSameType;
+module.exports = main;
diff --git a/is-same-value-zero/lib/index.js b/is-same-value-zero/lib/index.js
index e3b61bcc..88316ec3 100644
--- a/is-same-value-zero/lib/index.js
+++ b/is-same-value-zero/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isSameValueZero = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSameValueZero;
+module.exports = main;
diff --git a/is-same-value/lib/index.js b/is-same-value/lib/index.js
index 9956bfb6..f93dbfdc 100644
--- a/is-same-value/lib/index.js
+++ b/is-same-value/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isSameValue = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSameValue;
+module.exports = main;
diff --git a/is-semver/README.md b/is-semver/README.md
index 6bf51939..4e23fe5c 100644
--- a/is-semver/README.md
+++ b/is-semver/README.md
@@ -93,12 +93,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'1.0.0\n0.3' | is-semver --split /\r?\n/
+ # Escaped...
+ $ echo -n $'1.0.0\n0.3' | is-semver --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -118,6 +140,14 @@ $ echo -n 0.2.1-beta.1 | is-semver
true
```
+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 '1.0.0\t123' | is-semver --split '\t'
+true
+false
+```
+
@@ -142,6 +172,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-semver/bin/cli b/is-semver/bin/cli
index c192f222..bc23d80e 100755
--- a/is-semver/bin/cli
+++ b/is-semver/bin/cli
@@ -28,6 +28,8 @@ 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 isSemVer = require( './../lib' );
@@ -40,6 +42,7 @@ var isSemVer = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isSemVer( String( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isSemVer( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-semver/docs/usage.txt b/is-semver/docs/usage.txt
index 3a9c15f9..a1cc37ae 100644
--- a/is-semver/docs/usage.txt
+++ b/is-semver/docs/usage.txt
@@ -5,3 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-semver/etc/cli_opts.json b/is-semver/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-semver/etc/cli_opts.json
+++ b/is-semver/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-semver/test/test.cli.js b/is-semver/test/test.cli.js
index 5b796ac5..cfb0c3be 100644
--- a/is-semver/test/test.cli.js
+++ b/is-semver/test/test.cli.js
@@ -187,6 +187,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'1.0.0\t0.3\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'1.0.0\t0.3\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-sharedarraybuffer/lib/index.js b/is-sharedarraybuffer/lib/index.js
index 48d0956a..de1fd6c5 100644
--- a/is-sharedarraybuffer/lib/index.js
+++ b/is-sharedarraybuffer/lib/index.js
@@ -40,9 +40,9 @@
// MODULES //
-var isSharedArrayBuffer = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSharedArrayBuffer;
+module.exports = main;
diff --git a/is-skew-centrosymmetric-matrix/lib/index.js b/is-skew-centrosymmetric-matrix/lib/index.js
index 30be26f3..570dada4 100644
--- a/is-skew-centrosymmetric-matrix/lib/index.js
+++ b/is-skew-centrosymmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isSkewCentrosymmetricMatrix = require( './main.js' ); // eslint-disable-line id-length
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSkewCentrosymmetricMatrix;
+module.exports = main;
diff --git a/is-skew-persymmetric-matrix/lib/index.js b/is-skew-persymmetric-matrix/lib/index.js
index e6d7be2a..f1a3ebec 100644
--- a/is-skew-persymmetric-matrix/lib/index.js
+++ b/is-skew-persymmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isSkewPersymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSkewPersymmetricMatrix;
+module.exports = main;
diff --git a/is-skew-symmetric-matrix/lib/index.js b/is-skew-symmetric-matrix/lib/index.js
index bbaa50f8..bee065b1 100644
--- a/is-skew-symmetric-matrix/lib/index.js
+++ b/is-skew-symmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isSkewSymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSkewSymmetricMatrix;
+module.exports = main;
diff --git a/is-square-matrix/lib/index.js b/is-square-matrix/lib/index.js
index ef66b92a..315bd7d5 100644
--- a/is-square-matrix/lib/index.js
+++ b/is-square-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isSquareMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSquareMatrix;
+module.exports = main;
diff --git a/is-square-number/lib/index.js b/is-square-number/lib/index.js
index ae058cfb..7e74d0a2 100644
--- a/is-square-number/lib/index.js
+++ b/is-square-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isSquareNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isSquareNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isSquareNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isSquareNumber;
+module.exports = main;
diff --git a/is-square-triangular-number/lib/index.js b/is-square-triangular-number/lib/index.js
index d7ce5be0..d719fc4f 100644
--- a/is-square-triangular-number/lib/index.js
+++ b/is-square-triangular-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isSquareTriangularNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isSquareTriangularNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isSquareTriangularNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isSquareTriangularNumber;
+module.exports = main;
diff --git a/is-strict-equal/lib/index.js b/is-strict-equal/lib/index.js
index ba0a5f1e..9b8f42c4 100644
--- a/is-strict-equal/lib/index.js
+++ b/is-strict-equal/lib/index.js
@@ -50,9 +50,9 @@
// MODULES //
-var isStrictEqual = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isStrictEqual;
+module.exports = main;
diff --git a/is-string/lib/index.js b/is-string/lib/index.js
index 2793c6e0..f3a4974b 100644
--- a/is-string/lib/index.js
+++ b/is-string/lib/index.js
@@ -57,17 +57,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isString = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isString, 'isPrimitive', isPrimitive );
-setReadOnly( isString, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isString;
+module.exports = main;
diff --git a/is-symmetric-matrix/lib/index.js b/is-symmetric-matrix/lib/index.js
index ec30cd99..e45d419c 100644
--- a/is-symmetric-matrix/lib/index.js
+++ b/is-symmetric-matrix/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isSymmetricMatrix = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSymmetricMatrix;
+module.exports = main;
diff --git a/is-syntax-error/lib/index.js b/is-syntax-error/lib/index.js
index cc3f33ca..69b73242 100644
--- a/is-syntax-error/lib/index.js
+++ b/is-syntax-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isSyntaxError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isSyntaxError;
+module.exports = main;
diff --git a/is-touch-device/lib/index.js b/is-touch-device/lib/index.js
index 9aa5a55e..dcd8f86a 100644
--- a/is-touch-device/lib/index.js
+++ b/is-touch-device/lib/index.js
@@ -32,14 +32,14 @@
// MODULES //
-var isTouchDevice = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var IS_TOUCH_DEVICE = isTouchDevice();
+var bool = main();
// EXPORTS //
-module.exports = IS_TOUCH_DEVICE;
+module.exports = bool;
diff --git a/is-triangular-number/lib/index.js b/is-triangular-number/lib/index.js
index f4b24bc5..cd0b4525 100644
--- a/is-triangular-number/lib/index.js
+++ b/is-triangular-number/lib/index.js
@@ -63,17 +63,17 @@
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var isTriangularNumber = require( './main.js' );
+var main = require( './main.js' );
var isPrimitive = require( './primitive.js' );
var isObject = require( './object.js' );
// MAIN //
-setReadOnly( isTriangularNumber, 'isPrimitive', isPrimitive );
-setReadOnly( isTriangularNumber, 'isObject', isObject );
+setReadOnly( main, 'isPrimitive', isPrimitive );
+setReadOnly( main, 'isObject', isObject );
// EXPORTS //
-module.exports = isTriangularNumber;
+module.exports = main;
diff --git a/is-truthy-array/lib/index.js b/is-truthy-array/lib/index.js
index 9cbed941..e4352602 100644
--- a/is-truthy-array/lib/index.js
+++ b/is-truthy-array/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isTruthyArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTruthyArray;
+module.exports = main;
diff --git a/is-truthy/lib/index.js b/is-truthy/lib/index.js
index 6e15618b..0308558e 100644
--- a/is-truthy/lib/index.js
+++ b/is-truthy/lib/index.js
@@ -53,9 +53,9 @@
// MODULES //
-var isTruthy = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTruthy;
+module.exports = main;
diff --git a/is-type-error/lib/index.js b/is-type-error/lib/index.js
index f927369d..3b8b927b 100644
--- a/is-type-error/lib/index.js
+++ b/is-type-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isTypeError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTypeError;
+module.exports = main;
diff --git a/is-typed-array-length/lib/index.js b/is-typed-array-length/lib/index.js
index e82ccd61..39768893 100644
--- a/is-typed-array-length/lib/index.js
+++ b/is-typed-array-length/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isTypedArrayLength = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTypedArrayLength;
+module.exports = main;
diff --git a/is-typed-array-like/lib/index.js b/is-typed-array-like/lib/index.js
index b343e420..d8b1a4c9 100644
--- a/is-typed-array-like/lib/index.js
+++ b/is-typed-array-like/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isTypedArrayLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTypedArrayLike;
+module.exports = main;
diff --git a/is-typed-array/lib/index.js b/is-typed-array/lib/index.js
index 8df49952..ece7dd91 100644
--- a/is-typed-array/lib/index.js
+++ b/is-typed-array/lib/index.js
@@ -33,9 +33,9 @@
// MODULES //
-var isTypedArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isTypedArray;
+module.exports = main;
diff --git a/is-unc-path/README.md b/is-unc-path/README.md
index 7ee48a73..79d9740f 100644
--- a/is-unc-path/README.md
+++ b/is-unc-path/README.md
@@ -182,12 +182,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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/../bar\n\\\\server\\share\\foo' | is-unc-path --split /\r?\n/
+ # Escaped...
+ $ echo -n $'/foo/../bar\n\\\\server\\share\\foo' | is-unc-path --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -204,6 +226,14 @@ $ echo -n '\\\\server\\share\\foo' | is-unc-path
true
```
+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 '\\\\server\\share\\foo'\t/foo/../bar' | is-ascii --split '\t'
+true
+false
+```
+
@@ -228,6 +258,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-unc-path/bin/cli b/is-unc-path/bin/cli
index 8e83673a..f61a8ab3 100755
--- a/is-unc-path/bin/cli
+++ b/is-unc-path/bin/cli
@@ -29,6 +29,8 @@ var trim = require( '@stdlib/string/trim' );
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 isUNCPath = require( './../lib' );
@@ -41,6 +43,7 @@ var isUNCPath = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -65,6 +68,14 @@ function main() {
// 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( isUNCPath( trim( args[ 0 ] ) ) ); // eslint-disable-line no-console
@@ -83,7 +94,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isUNCPath( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-unc-path/docs/usage.txt b/is-unc-path/docs/usage.txt
index 43dfb0be..fe6c5938 100644
--- a/is-unc-path/docs/usage.txt
+++ b/is-unc-path/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-unc-path/etc/cli_opts.json b/is-unc-path/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-unc-path/etc/cli_opts.json
+++ b/is-unc-path/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-unc-path/lib/index.js b/is-unc-path/lib/index.js
index 44a74ccc..9f99fcf8 100644
--- a/is-unc-path/lib/index.js
+++ b/is-unc-path/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isUNCPath = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isUNCPath;
+module.exports = main;
diff --git a/is-unc-path/test/test.cli.js b/is-unc-path/test/test.cli.js
index a7c7c791..ff716b91 100644
--- a/is-unc-path/test/test.cli.js
+++ b/is-unc-path/test/test.cli.js
@@ -184,6 +184,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+tape( 'the command-line interface supports specifying a custom delimiter when used as a standard stream (string)', opts, function test( t ) {
+ var cmd = [
+ 'printf \'\\\\server\\share\\foo\t/foo/../bar\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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 \'\\\\server\\share\\foo\t/foo/../bar\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'true\nfalse\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;
diff --git a/is-undefined-or-null/lib/index.js b/is-undefined-or-null/lib/index.js
index cf7b177a..34cd1d84 100644
--- a/is-undefined-or-null/lib/index.js
+++ b/is-undefined-or-null/lib/index.js
@@ -38,9 +38,9 @@
// MODULES //
-var isUndefinedOrNull = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isUndefinedOrNull;
+module.exports = main;
diff --git a/is-undefined/lib/index.js b/is-undefined/lib/index.js
index d861778a..4396f466 100644
--- a/is-undefined/lib/index.js
+++ b/is-undefined/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isUndefined = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isUndefined;
+module.exports = main;
diff --git a/is-unity-probability-array/lib/index.js b/is-unity-probability-array/lib/index.js
index 62734d96..3ac406eb 100644
--- a/is-unity-probability-array/lib/index.js
+++ b/is-unity-probability-array/lib/index.js
@@ -41,9 +41,9 @@
// MODULES //
-var isUnityProbabilityArray = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isUnityProbabilityArray;
+module.exports = main;
diff --git a/is-uppercase/README.md b/is-uppercase/README.md
index 9c9ad070..eac783ab 100644
--- a/is-uppercase/README.md
+++ b/is-uppercase/README.md
@@ -99,12 +99,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\nFOO' | is-uppercase --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\nFOO' | is-uppercase --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -121,6 +143,14 @@ $ echo -n 'boop' | is-uppercase
false
```
+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' | is-uppercase --split '\t'
+true
+false
+```
+
@@ -150,6 +180,8 @@ false
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
[@stdlib/assert/is-lowercase]: https://github.com/stdlib-js/assert/tree/main/is-lowercase
diff --git a/is-uppercase/bin/cli b/is-uppercase/bin/cli
index 860828a5..d887b505 100755
--- a/is-uppercase/bin/cli
+++ b/is-uppercase/bin/cli
@@ -28,6 +28,8 @@ 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 isUppercase = require( './../lib' );
@@ -40,6 +42,7 @@ var isUppercase = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isUppercase( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isUppercase( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-uppercase/docs/usage.txt b/is-uppercase/docs/usage.txt
index 67797f84..41979e01 100644
--- a/is-uppercase/docs/usage.txt
+++ b/is-uppercase/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-uppercase/etc/cli_opts.json b/is-uppercase/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-uppercase/etc/cli_opts.json
+++ b/is-uppercase/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-uppercase/lib/index.js b/is-uppercase/lib/index.js
index 5bf4f484..dc3ce3ec 100644
--- a/is-uppercase/lib/index.js
+++ b/is-uppercase/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isUppercase = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isUppercase;
+module.exports = main;
diff --git a/is-uppercase/test/test.cli.js b/is-uppercase/test/test.cli.js
index a6a922a1..6890d84c 100644
--- a/is-uppercase/test/test.cli.js
+++ b/is-uppercase/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\tFOO BAR\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\tFOO BAR\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-uri-error/lib/index.js b/is-uri-error/lib/index.js
index 5c4e95de..4b08962a 100644
--- a/is-uri-error/lib/index.js
+++ b/is-uri-error/lib/index.js
@@ -35,9 +35,9 @@
// MODULES //
-var isURIError = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isURIError;
+module.exports = main;
diff --git a/is-uri/README.md b/is-uri/README.md
index f6bd00d1..c50e2d12 100644
--- a/is-uri/README.md
+++ b/is-uri/README.md
@@ -180,12 +180,34 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
+ --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 $'beEp booP\nhttp://google.com' | is-uri --split /\r?\n/
+ # Escaped...
+ $ echo -n $'beEp booP\nhttp://google.com' | is-uri --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
### Examples
@@ -202,6 +224,14 @@ $ echo -n 'http://google.com' | is-uri
true
```
+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\thttps://google.com' | is-uri --split '\t'
+false
+true
+```
+
@@ -230,6 +260,8 @@ true
[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
+[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+
diff --git a/is-uri/bin/cli b/is-uri/bin/cli
index b70fdbf4..4ae37cc0 100755
--- a/is-uri/bin/cli
+++ b/is-uri/bin/cli
@@ -28,6 +28,8 @@ 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 isURI = require( './../lib' );
@@ -40,6 +42,7 @@ var isURI = require( './../lib' );
* @returns {void}
*/
function main() {
+ var split;
var flags;
var args;
var cli;
@@ -64,6 +67,14 @@ function main() {
// 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( isURI( args[ 0 ] ) ); // eslint-disable-line no-console
@@ -82,7 +93,12 @@ function main() {
if ( error ) {
return cli.error( error );
}
- lines = data.toString().split( RE_EOL );
+ 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( isURI( lines[ i ] ) ); // eslint-disable-line no-console
}
diff --git a/is-uri/docs/usage.txt b/is-uri/docs/usage.txt
index 63479c9a..a7cc2645 100644
--- a/is-uri/docs/usage.txt
+++ b/is-uri/docs/usage.txt
@@ -5,4 +5,4 @@ Options:
-h, --help Print this message.
-V, --version Print the package version.
-
+ --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
diff --git a/is-uri/etc/cli_opts.json b/is-uri/etc/cli_opts.json
index f245a17e..7c40f9a1 100644
--- a/is-uri/etc/cli_opts.json
+++ b/is-uri/etc/cli_opts.json
@@ -1,4 +1,7 @@
{
+ "string": [
+ "split"
+ ],
"boolean": [
"help",
"version"
diff --git a/is-uri/lib/index.js b/is-uri/lib/index.js
index d7fa6a7c..53adb464 100644
--- a/is-uri/lib/index.js
+++ b/is-uri/lib/index.js
@@ -102,9 +102,9 @@
// MODULES //
-var isURI = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isURI;
+module.exports = main;
diff --git a/is-uri/test/test.cli.js b/is-uri/test/test.cli.js
index 1d076f38..cafc5a18 100644
--- a/is-uri/test/test.cli.js
+++ b/is-uri/test/test.cli.js
@@ -183,6 +183,50 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
}
});
+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\thttp://google.com\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split \'\t\''
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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\thttp://google.com\'',
+ '|',
+ EXEC_PATH,
+ fpath,
+ '--split=/\\\\t/'
+ ];
+
+ exec( cmd.join( ' ' ), done );
+
+ function done( error, stdout, stderr ) {
+ if ( error ) {
+ t.fail( error.message );
+ } else {
+ t.strictEqual( stdout.toString(), 'false\ntrue\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;
diff --git a/is-vector-like/lib/index.js b/is-vector-like/lib/index.js
index 6192f4b9..f4d2e981 100644
--- a/is-vector-like/lib/index.js
+++ b/is-vector-like/lib/index.js
@@ -37,9 +37,9 @@
// MODULES //
-var isVectorLike = require( './main.js' );
+var main = require( './main.js' );
// EXPORTS //
-module.exports = isVectorLike;
+module.exports = main;
diff --git a/is-web-worker/lib/index.js b/is-web-worker/lib/index.js
index c87d804e..b590e664 100644
--- a/is-web-worker/lib/index.js
+++ b/is-web-worker/lib/index.js
@@ -32,12 +32,12 @@
// MODULES //
-var isWebWorker = require( './main.js' );
+var main = require( './main.js' );
// MAIN //
-var bool = isWebWorker();
+var bool = main();
// EXPORTS //
diff --git a/is-whitespace/README.md b/is-whitespace/README.md
index 144a989e..fea0b3d3 100644
--- a/is-whitespace/README.md
+++ b/is-whitespace/README.md
@@ -80,6 +80,85 @@ out = isWhitespace( 123 );
+* * *
+
+
+
+## CLI
+
+
+
+### Usage
+
+```text
+Usage: is-whitespace [options] []
+
+Options:
+
+ -h, --help Print this message.
+ -V, --version Print the package version.
+ --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 $' \nboop' | is-whitespace --split /\r?\n/
+
+ # Escaped...
+ $ echo -n $' \nboop' | is-whitespace --split /\\r?\\n/
+ ```
+
+- The implementation ignores trailing delimiters.
+
+
+
+
+
+
+
+### Examples
+
+```bash
+$ is-whitespace foo
+false
+```
+
+To use as a [standard stream][standard-streams],
+
+```bash
+$ echo -n 'foo' | is-whitespace
+false
+```
+
+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 ' \tbar' | is-whitespace --split '\t'
+true
+false
+```
+
+
+
+
+
+
+
+
+
+