diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/README.md b/lib/node_modules/@stdlib/utils/parse-ndjson/README.md
new file mode 100644
index 000000000000..b5ef90096964
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/README.md
@@ -0,0 +1,176 @@
+
+
+# parseNDJSON
+
+> Parse a string containing serialized newline-delimited [JSON][json] (NDJSON).
+
+
+
+## Usage
+
+```javascript
+var parseNDJSON = require( '@stdlib/utils/parse-ndjson' );
+```
+
+#### parseNDJSON( str\[, reviver] )
+
+Parses a `string` as `newline-delimited JSON`.
+
+```javascript
+var out = parseNDJSON( '{"beep":"boop"}\n{"example":42}' );
+// returns [ { 'beep': 'boop' }, { 'example': 42 } ]
+```
+
+To transform the `string` being parsed, provide a `reviver`.
+
+```javascript
+function reviver( key, value ) {
+ if ( key === '' || key === 'beep' ) {
+ return ( typeof value === 'string' ) ? value.toUpperCase() : value;
+ }
+ return ( typeof value === 'number' ) ? value * 2 : value;
+}
+
+var str = '{"beep":"boop"}\n{"value": 20}\n{"numbers": [1,2,3]}';
+var out = parseNDJSON( str, reviver );
+// returns [ { 'beep' : 'BOOP' }, { 'value': 40 }, { 'numbers': [ 2, 4, 6 ] } ]
+```
+
+
+
+
+
+
+
+## Notes
+
+- In contrast to the native [`JSON.parse()`][json-parse], this implementation parses `string` as `newline-delimited JSON` and returns an array of parsed JSONs.
+
+ ```javascript
+ var out = JSON.parse( '{"beep":"boop"}\n{"foo":"baz"}' );
+ // throws
+
+ out = parseNDJSON( '{"beep":"boop"}\n{"foo":"baz"}' );
+ // returns [ { 'beep': 'boop' }, { 'foo': 'baz' } ]
+ ```
+
+
+- In contrast to the native [`JSON.parse()`][json-parse], this implementation throws a TypeError if provided any value which is not a `string`.
+
+ ```javascript
+ var out = JSON.parse( null );
+ // returns null
+
+ out = parseNDJSON( null );
+ // throws
+ ```
+
+
+- In contrast to the native [`JSON.parse()`][json-parse], this implementation does **not** throw a SyntaxError if unable to parse a string as newline-delimited JSON.
+
+ ```javascript
+ var out = parseNDJSON( '{"beep":boop}' );
+ // returns
+
+ out = JSON.parse( '{"beep":boop}' );
+ // throws
+ ```
+
+
+- In contrast to the native [`JSON.parse()`][json-parse], this implementation throws a TypeError if provided a reviver argument which is not a function.
+
+ ```javascript
+ var out = JSON.parse( '{"a":"b"}', [] );
+ // returns { 'a': 'b' }
+
+ out = parseNDJSON( '{"a":"b"}', [] );
+ // throws
+ ```
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var parseNDJSON = require( '@stdlib/utils/parse-ndjson' );
+
+var out = parseNDJSON( '{"name":"John"}\n{"name":"Doe"}' );
+// returns [ { 'name': 'John' }, { 'name': 'Doe' } ]
+
+function reviver( key, value ) {
+ if ( key === 'name' ) {
+ return value.toUpperCase();
+ }
+ return value;
+}
+
+out = parseNDJSON( '{"name":"John"}\n{"name":"Doe"}', reviver );
+// returns [ { 'name': 'JOHN' }, { 'name': 'DOE' } ]
+
+out = parseNDJSON( '{"name":John}\n{"name":Doe}' );
+// returns
+
+out = parseNDJSON( ' ' );
+// returns []
+
+out = parseNDJSON( '{}' );
+// returns [ {} ]
+
+out = parseNDJSON( '{"name":"Eve"}\n42\ntrue\n[1,2,3]' );
+// returns [ { 'name': 'Eve' }, 42, true, [ 1, 2, 3 ] ]
+
+out = parseNDJSON( '{"name":"John"}\r\n{"name":"Doe"}' );
+// returns [ { 'name': 'John' }, { 'name': 'Doe' } ]
+
+out = parseNDJSON( '{"name":"John"}\n{"name":"Doe"}\n' );
+// returns [ { 'name': 'John' }, { 'name': 'Doe' } ]
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[json]: http://www.json.org/
+
+[json-parse]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
+
+
+
+
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/parse-ndjson/benchmark/benchmark.js
new file mode 100644
index 000000000000..899d4481cb21
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/benchmark/benchmark.js
@@ -0,0 +1,61 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var fromCodePoint = require( '@stdlib/string/from-code-point' );
+var pkg = require( './../package.json' ).name;
+var parseNDJSON = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var str;
+ var out;
+ var i;
+ var j;
+
+ b.tic();
+
+ for ( i = 0; i < b.iterations; i++ ) {
+ // Generate an NDJSON string with a changing property key in each line:
+ str = '{"beep":"boop","'+fromCodePoint( 97 + (i%26) ) + '":true}\n{"example":' + i + '}';
+ out = parseNDJSON( str );
+
+ if ( out !== out ) {
+ b.fail( 'should return an array of JSON objects' );
+ }
+ }
+
+ b.toc();
+
+ for ( j = 0; j < out.length; j++ ) {
+ if ( out[j] instanceof Error ) {
+ b.fail( 'should return an array of JSON objects' );
+ }
+ }
+
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+// TODO: Add benchmarks with different sized NDJSON strings
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/docs/repl.txt b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/repl.txt
new file mode 100644
index 000000000000..45b1efe7788e
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/repl.txt
@@ -0,0 +1,45 @@
+
+{{alias}}( str[, reviver] )
+ Attempts to parse a string as newline-delimited JSON (NDJSON).
+
+ Function behavior differs from `JSON.parse()` as follows:
+
+ - Returns array of parsed JSON
+ - Throws a `TypeError` if provided any value which is not a string.
+ - Returns a `SyntaxError` if unable to parse a string as NDJSON.
+ - Throws a `TypeError` if provided a `reviver` argument which
+ is not a function.
+
+ Parameters
+ ----------
+ str: string
+ String to parse as newline-delimited JSON.
+
+ reviver: Function (optional)
+ Transformation function.
+
+ Returns
+ -------
+ out: Array | Error
+ Array of parsed values or an error.
+
+ Examples
+ --------
+ > var obj = '{"beep":"boop"}\n{"example":42}\n{"data":[1,2,3]}';
+ > var result = {{alias}}( obj )
+ [ { 'beep': 'boop' }, { 'example': 42 }, { 'data': [ 1, 2, 3 ] } ]
+
+ // Provide a reviver:
+ > function reviver( key, value ) {
+ ... if ( key === '' || key === 'beep' ) {
+ ... return ( typeof value === 'string' )
+ ... ? value.toUpperCase() : value;
+ ... };
+ ... return typeof value === 'number' ? value * 2 : value;
+ ... };
+ > var ndjsonString = '{"beep":"boop"}\n{"example":42}\n{"data":[1,2,3]}';
+ > var resultWithReviver = {{alias}}( ndjsonString, reviver )
+ [ { 'beep': 'boop' }, { 'example': 84 }, { 'data': [ 2, 4, 6 ] } ]
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/index.d.ts
new file mode 100644
index 000000000000..952badea34db
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/index.d.ts
@@ -0,0 +1,38 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+/**
+* Parses a string as newline-delimited JSON (NDJSON).
+*
+* @param str - input string containing NDJSON
+* @param reviver - transformation function applied to each line
+* @returns array of parsed values or an error
+*
+* @example
+* var arr = parseNDJSON( '{"beep":"boop"}\\n{"example":42}\\n{"data":[1,2,3]}' );
+* // returns [ { 'beep': 'boop' }, { 'example': 42 }, { 'data': [ 1, 2, 3 ] } ]
+*/
+
+declare function parseNDJSON( str: string, reviver?: Function ): Array | Error;
+
+
+// EXPORTS //
+
+export = parseNDJSON;
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/test.ts b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/test.ts
new file mode 100644
index 000000000000..a113d7b3337d
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/docs/types/test.ts
@@ -0,0 +1,54 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import parseNDJSON = require( './index' );
+
+
+// TESTS //
+
+// The function returns an array of parsed values...
+{
+ const validNDJSON = '{"beep":"boop"}\n{"example":42}\n{"data":[1,2,3]}';
+ parseNDJSON( validNDJSON ); // $ExpectType any[] | Error
+}
+
+// The function does not compile if the argument is a value other than a string...
+{
+ parseNDJSON( true ); // $ExpectError
+ parseNDJSON( false ); // $ExpectError
+ parseNDJSON( 5 ); // $ExpectError
+ parseNDJSON( [] ); // $ExpectError
+ parseNDJSON( {} ); // $ExpectError
+ parseNDJSON( ( x: number ): number => x ); // $ExpectError
+}
+
+// The function does not compile if the second argument is a value other than a function...
+{
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', true ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', false ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', 5 ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', [] ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', {} ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}\n{"example":42}', 'baz' ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ parseNDJSON( ); // $ExpectError
+ parseNDJSON( '{"beep":"boop"}', 'baz', 'foo' ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/examples/index.js b/lib/node_modules/@stdlib/utils/parse-ndjson/examples/index.js
new file mode 100644
index 000000000000..e36618052378
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/examples/index.js
@@ -0,0 +1,77 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var isError = require( '@stdlib/assert/is-error' );
+var parseNDJSON = require( './../lib' );
+
+var str = '{"name":"John"}\n{"name":"Doe"}';
+
+// Example 1: Parse a simple NDJSON string
+var out = parseNDJSON( str );
+console.log( out );
+// => [ { 'name': 'John' }, { 'name': 'Doe' } ]
+
+// Example 2: Parse an NDJSON string with a reviver function
+function reviver( key, value ) {
+ if ( key === 'name' ) {
+ return value.toUpperCase();
+ }
+ return value;
+}
+
+out = parseNDJSON( str, reviver );
+console.log( out );
+// => [ { 'name': 'JOHN' }, { 'name': 'DOE' } ]
+
+// Example 3: Parse an NDJSON string with an error (missing closing double quote)
+str = '{"name":John}\n{"name":Doe}';
+out = parseNDJSON( str );
+console.log( isError( out ) );
+// => true
+
+// Example 4: Parse an empty NDJSON string
+str = '';
+out = parseNDJSON( str );
+console.log( out );
+// => []
+
+// Example 5: Parse an NDJSON string with a single empty object
+str = '{}';
+out = parseNDJSON( str );
+console.log( out );
+// => [ {} ]
+
+// Example 6: Parse an NDJSON string with different data types
+str = '{"name":"Eve"}\n42\ntrue\n[1,2,3]\r\n';
+out = parseNDJSON( str );
+console.log( out );
+// => [ { 'name': 'Eve' }, 42, true, [1,2,3] ]
+
+// Example 7: Parse a simple NDJSON string, followed by a trailing newline
+str = '{"name":"John"}\n{"name":"Doe"}\n';
+out = parseNDJSON( str );
+console.log( out );
+// => [ { 'name': 'John' }, { 'name': 'Doe' } ]
+
+// Example 8: Parse a simple NDJSON string, with alternate newline characters
+str = '{"beep":"boop"}\r\n{"foo":"baz"}';
+out = parseNDJSON( str );
+console.log( out );
+// => [ { 'beep': 'boop' }, { 'foo': 'baz' } ]
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/lib/index.js b/lib/node_modules/@stdlib/utils/parse-ndjson/lib/index.js
new file mode 100644
index 000000000000..1b77cbaf7689
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/lib/index.js
@@ -0,0 +1,41 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Parse a string as newline-delimited JSON (NDJSON).
+*
+* @module @stdlib/utils/parse-ndjson
+*
+* @example
+* var parseNDJSON = require( '@stdlib/utils/parse-ndjson' );
+*
+* var out = parseNDJSON( '{"beep":"boop"}\n{"example":42}' );
+* // returns [ { 'beep': 'boop' }, { 'example': 42 } ]
+*/
+
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/lib/main.js b/lib/node_modules/@stdlib/utils/parse-ndjson/lib/main.js
new file mode 100644
index 000000000000..59554ed9d215
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/lib/main.js
@@ -0,0 +1,92 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var isFunction = require( '@stdlib/assert/is-function' );
+var parseJSON = require( '@stdlib/utils/parse-json' );
+var format = require( '@stdlib/string/format' );
+var isWhitespace = require( '@stdlib/assert/is-whitespace' );
+var reEOL = require( '@stdlib/regexp/eol' );
+
+
+// MAIN //
+
+/**
+* Parses a string as newline-delimited JSON (NDJSON).
+*
+* @param {string} str - input string
+* @param {Function} [reviver] - transformation function applied to each line
+* @throws {TypeError} first argument must be a string
+* @throws {TypeError} reviver must be a function
+* @returns {Array|Error} array of parsed values or an error
+*
+* @example
+* var out = parseNDJSON( '{"name":"John"}\n{"name":"Doe"}' );
+* // returns [ { 'name': 'John' }, { 'name': 'Doe' } ]
+*/
+function parseNDJSON( str, reviver ) {
+ var parsed;
+ var RE_EOL;
+ var lines;
+ var out;
+ var i;
+
+ if ( !isString( str ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
+ }
+ if ( arguments.length > 1 && !isFunction( reviver ) ) {
+ throw new TypeError( format( 'invalid argument. Reviver argument must be a function. Value: `%s`.', str ) );
+ }
+ if ( isWhitespace( str ) || str === '' ) {
+ return [];
+ }
+
+ RE_EOL = reEOL();
+
+ lines = str.split( RE_EOL );
+
+ // Remove trailing newline:
+ if ( lines[ lines.length - 1 ].length === 0 ) {
+ lines.pop();
+ }
+
+ out = [];
+
+ for ( i = 0; i < lines.length; i++ ) {
+ if ( reviver ) {
+ parsed = parseJSON( lines[ i ], reviver );
+ } else {
+ parsed = parseJSON( lines[ i ] );
+ }
+ if ( parsed instanceof Error ) {
+ return parsed;
+ }
+
+ out.push( parsed );
+ }
+ return out;
+}
+
+
+// EXPORTS //
+
+module.exports = parseNDJSON;
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/package.json b/lib/node_modules/@stdlib/utils/parse-ndjson/package.json
new file mode 100644
index 000000000000..449f48247665
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "@stdlib/utils/parse-ndjson",
+ "version": "0.0.0",
+ "description": "Parse a string as Newline-Delimited JSON (NDJSON).",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {
+ "tape": "^5.7.5"
+ },
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdutils",
+ "stdutil",
+ "utilities",
+ "utility",
+ "utils",
+ "util",
+ "ndjson",
+ "parse",
+ "newline",
+ "json",
+ "string",
+ "str"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/utils/parse-ndjson/test/test.js b/lib/node_modules/@stdlib/utils/parse-ndjson/test/test.js
new file mode 100644
index 000000000000..69d26301ba4b
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/parse-ndjson/test/test.js
@@ -0,0 +1,178 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var noop = require( '@stdlib/utils/noop' );
+var parseNDJSON = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof parseNDJSON, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws if not provided a string', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ 3.14,
+ NaN,
+ true,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ parseNDJSON( value );
+ };
+ }
+});
+
+tape( 'the function throws if not provided a string (reviver)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ 3.14,
+ NaN,
+ true,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ parseNDJSON( value, noop );
+ };
+ }
+});
+
+tape( 'the function throws if provided a reviver argument which is not a function', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 3.14,
+ NaN,
+ true,
+ null,
+ void 0,
+ [],
+ {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ parseNDJSON( '{"a":"b"}\n{"c": "d"}', value );
+ };
+ }
+});
+
+tape( 'the function returns an array of parsed values if provided valid NDJSON', function test( t ) {
+ var expected;
+ var actual;
+
+ expected = [
+ {
+ 'beep': 'boop'
+ },
+ {
+ 'example': 42
+ },
+ {
+ 'data': [ 1, 2, 3 ]
+ }
+ ];
+ actual = parseNDJSON( '{"beep":"boop"}\n{"example":42}\n{"data":[1,2,3]}' );
+ t.deepEqual( actual, expected, 'deep equal' );
+
+ expected = [];
+ actual = parseNDJSON('');
+
+ t.deepEqual( actual, expected, 'returns an empty array' );
+
+ t.end();
+});
+
+tape( 'the function returns an error if provided invalid NDJSON', function test( t ) {
+ var out = parseNDJSON( '{"beep":"boop"' );
+ t.equal( out instanceof SyntaxError, true, 'returns an error' );
+ t.end();
+});
+
+tape( 'the function supports providing a custom reviver function', function test( t ) {
+ var expected;
+ var actual;
+ var str;
+
+ function reviver( key, value ) {
+ if ( key === '' || key === 'beep' ) {
+ return ( typeof value === 'string' ) ? value.toUpperCase() : value;
+ }
+ return ( typeof value === 'number' ) ? value * 2 : value;
+ }
+
+ str = '{"beep":"boop"}\n{"value": 20}\n{"numbers": [1,2,3]}';
+ expected = [
+ {
+ 'beep': 'BOOP'
+ },
+ {
+ 'value': 40
+ },
+ {
+ 'numbers': [ 2, 4, 6 ]
+ }
+ ];
+ actual = parseNDJSON( str, reviver );
+
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});