From d1d40dee568acc14d7b192acfeb48cc064071aad Mon Sep 17 00:00:00 2001 From: Rutam Kathale Date: Sat, 24 Feb 2024 17:15:28 +0530 Subject: [PATCH 01/15] feat(@stdlib/assert): if applied, this commit will add the function 'isRaggedNestedArray' (assert/is-ragged-nested-array) Add support for checking if array-like objects are ragged and nested. Fixes: #1347 Issue Link: https://github.com/stdlib-js/stdlib/issues/1347 --- .../assert/is-ragged-nested-array/README.md | 120 ++++++++++++++++++ .../benchmark/benchmark.js | 91 +++++++++++++ .../is-ragged-nested-array/docs/repl.txt | 27 ++++ .../docs/types/index.d.ts | 44 +++++++ .../is-ragged-nested-array/docs/types/test.ts | 34 +++++ .../is-ragged-nested-array/examples/index.js | 50 ++++++++ .../is-ragged-nested-array/lib/index.js | 46 +++++++ .../assert/is-ragged-nested-array/lib/main.js | 69 ++++++++++ .../is-ragged-nested-array/package.json | 77 +++++++++++ .../is-ragged-nested-array/test/test.js | 89 +++++++++++++ 10 files changed, 647 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md new file mode 100644 index 000000000000..2ca54cae3618 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md @@ -0,0 +1,120 @@ + + +# isRaggedNestedArray + +> Test if a value is a ragged nested array. + +
+ +## Usage + +```javascript +var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); +``` + +#### isRaggedNestedArray( value ) + +Tests if a value is a ragged nested array. A ragged nested array is a nested array having inner dimensions of varying lengths. + +```javascript +var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +// returns true + +bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +// returns false +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); + +var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +// returns true + +bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +// returns false + +bool = isRaggedNestedArray( 'beep' ); +// returns false + +bool = isRaggedNestedArray( null ); +// returns false + +bool = isRaggedNestedArray( void 0 ); +// returns false + +bool = isRaggedNestedArray( 5 ); +// returns false + +bool = isRaggedNestedArray( true ); +// returns false + +bool = isRaggedNestedArray( {} ); +// returns false + +bool = isRaggedNestedArray( function noop() {} ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js new file mode 100644 index 000000000000..7ca1a828fdd7 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 pkg = require( './../package.json' ).name; +var isRaggedNestedArray = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::ragged_array', function benchmark( b ) { + var bool; + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = [ [1, 2, 3], [4, 5] ]; + bool = isRaggedNestedArray( arr ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !bool ) { + b.fail( 'should return true' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::non_ragged_array', function benchmark( b ) { + var bool; + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = [ [1, 2, 3], [4, 5, 6] ]; + bool = isRaggedNestedArray( arr ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( bool ) { + b.fail( 'should return false' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::non_array', function benchmark( b ) { + var bool; + var val; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + val = 'beep'; + bool = isRaggedNestedArray( val ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( bool ) { + b.fail( 'should return false' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt new file mode 100644 index 000000000000..0f6fdc8f1d65 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -0,0 +1,27 @@ +{{alias}}( value ) + Tests if a value is a ragged nested array. A ragged nested array is a nested + array having inner dimensions of varying lengths. This function supports + two-dimensional nested arrays and uses isArrayLikeObject to check if a value + is an array-like object. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether a value is a ragged nested array. + + Examples + -------- + > var bool = {{alias}}( [ [1, 2, 3], [4, 5] ] ) + true + > bool = {{alias}}( [ [1, 2, 3], [4, 5, 6] ] ) + false + > bool = {{alias}}( 'beep' ) + false + + See Also + -------- diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts new file mode 100644 index 000000000000..37539589b108 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts @@ -0,0 +1,44 @@ +/* +* @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 + +/** +* Tests if a value is a ragged nested array. +* +* @param value - value to test +* @returns boolean indicating if a value is a ragged nested array +* +* @example +* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* // returns true +* +* @example +* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* // returns false +* +* @example +* var bool = isRaggedNestedArray( 'beep' ); +* // returns false +*/ +declare function isRaggedNestedArray( value: any ): value is ArrayLike; + + +// EXPORTS // + +export = isRaggedNestedArray; diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts new file mode 100644 index 000000000000..18f3afe46bd1 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 isRaggedNestedArray = require( './index' ); + +// TESTS // + +// The function returns a boolean... +{ + isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); // $ExpectType boolean + isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); // $ExpectType boolean + isRaggedNestedArray( 'beep' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isRaggedNestedArray(); // $ExpectError + isRaggedNestedArray( [], 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js new file mode 100644 index 000000000000..cc7a0e1acb63 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +*/ + +/* eslint-disable no-empty-function, no-restricted-syntax */ + +'use strict'; + +var isRaggedNestedArray = require( './../lib' ); + +console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ) ); +// => true + +console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ) ); +// => false + +console.log( isRaggedNestedArray( 'beep' ) ); +// => false + +console.log( isRaggedNestedArray( null ) ); +// => false + +console.log( isRaggedNestedArray( void 0 ) ); +// => false + +console.log( isRaggedNestedArray( 5 ) ); +// => false + +console.log( isRaggedNestedArray( true ) ); +// => false + +console.log( isRaggedNestedArray( {} ) ); +// => false + +console.log( isRaggedNestedArray( function noop() {} ) ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js new file mode 100644 index 000000000000..b92294bca993 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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'; + +/** +* Test if a value is a ragged nested array. +* +* @module @stdlib/assert/is-ragged-nested-array +* +* @example +* var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); +* +* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* // returns true +* +* bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* // returns false +* +* bool = isRaggedNestedArray( 'beep' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js new file mode 100644 index 000000000000..3b608b2d02b9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); + + +// MAIN // + +/** +* Tests if a value is a ragged nested array. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating if a value is a ragged nested array +* +* @example +* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* // returns true +* +* @example +* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* // returns false +* +* @example +* var bool = isRaggedNestedArray( 'beep' ); +* // returns false +*/ +function isRaggedNestedArray( value ) { + var len = -1; + var i; + + if ( !isArrayLikeObject( value ) ) { + return false; + } + for ( i = 0; i < value.length; i++ ) { + if ( !isArrayLikeObject( value[i] ) ) { + return false; + } + if ( len === -1 ) { + len = value[i].length; + } else if ( value[i].length !== len ) { + return true; + } + } + return false; +} + + +// EXPORTS // + +module.exports = isRaggedNestedArray; diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json new file mode 100644 index 000000000000..0071e72596ab --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/assert/is-ragged-nested-array", + "version": "0.0.0", + "description": "Test if a value is a ragged nested array", + "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": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "array", + "ragged", + "nested", + "is", + "israggednestedarray", + "object", + "obj", + "type", + "check", + "test", + "validate", + "isvalid", + "2d", + "two-dimensional" + ] + + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js new file mode 100644 index 000000000000..660ec9b4f522 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +*/ + +/* eslint-disable no-unused-vars */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isRaggedNestedArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isRaggedNestedArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a ragged nested array', function test( t ) { + var values; + var i; + + values = [ + [ [1, 2, 3], [4, 5] ], + [ [1, 2, 3], [4, 5, 6, 7] ], + [ [1], [2, 3], [4, 5, 6] ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isRaggedNestedArray( values[i] ), true, 'returns true when provided '+values[i] ); + } + t.end(); +}); + +tape( 'the function returns `false` if provided a non-ragged nested array', function test( t ) { + var values; + var i; + + values = [ + [ [1, 2, 3], [4, 5, 6] ], + [ [1, 2], [3, 4], [5, 6] ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isRaggedNestedArray( values[i] ), false, 'returns false when provided '+values[i] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a nested array', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 5, + null, + void 0, + NaN, + true, + false, + {}, + function boop( a, b, c ) {}, + [1, 2, 3] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isRaggedNestedArray( values[i] ), false, 'returns false when provided '+values[i] ); + } + t.end(); +}); From 930e28e02bb185b7136ab3588dafe980b8b4f5d8 Mon Sep 17 00:00:00 2001 From: Rutam Kathale Date: Sat, 24 Feb 2024 23:11:01 +0530 Subject: [PATCH 02/15] feat(@stdlib/assert): if applied, this commit will add the function isRaggedNestedArray' (Revision 1) Add support for checking if array-like objects are ragged and nested. Signed-off-by: Pranavchiku goswami.4@iitj.ac.in --- .../is-ragged-nested-array/benchmark/benchmark.js | 8 ++++---- .../assert/is-ragged-nested-array/docs/repl.txt | 13 +++++-------- .../is-ragged-nested-array/docs/types/test.ts | 2 +- .../assert/is-ragged-nested-array/examples/index.js | 2 +- .../assert/is-ragged-nested-array/lib/index.js | 2 +- .../assert/is-ragged-nested-array/lib/main.js | 2 +- .../assert/is-ragged-nested-array/package.json | 4 +--- .../assert/is-ragged-nested-array/test/test.js | 2 +- 8 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js index 7ca1a828fdd7..23dacb4f464a 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. @@ -34,7 +34,7 @@ bench( pkg+'::ragged_array', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = [ [1, 2, 3], [4, 5] ]; + arr = [ [i, i+1, i+2], [i-1, i-2] ]; bool = isRaggedNestedArray( arr ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); @@ -55,7 +55,7 @@ bench( pkg+'::non_ragged_array', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = [ [1, 2, 3], [4, 5, 6] ]; + arr = [ [i, i+1], [i-1, i] ]; bool = isRaggedNestedArray( arr ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); @@ -76,7 +76,7 @@ bench( pkg+'::non_array', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - val = 'beep'; + val = i; bool = isRaggedNestedArray( val ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt index 0f6fdc8f1d65..b861e542d4f3 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -1,8 +1,5 @@ -{{alias}}( value ) - Tests if a value is a ragged nested array. A ragged nested array is a nested - array having inner dimensions of varying lengths. This function supports - two-dimensional nested arrays and uses isArrayLikeObject to check if a value - is an array-like object. +{{alias}}(value) + Tests if a value is a ragged nested array. Parameters ---------- @@ -16,11 +13,11 @@ Examples -------- - > var bool = {{alias}}( [ [1, 2, 3], [4, 5] ] ) + > var bool = {{alias}}([ [1, 2, 3], [4, 5] ]) true - > bool = {{alias}}( [ [1, 2, 3], [4, 5, 6] ] ) + > bool = {{alias}}([ [1, 2, 3], [4, 5, 6] ]) false - > bool = {{alias}}( 'beep' ) + > bool = {{alias}}('beep') false See Also diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts index 18f3afe46bd1..5d6031981d86 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js index cc7a0e1acb63..29a62f4efa56 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js index b92294bca993..082ae03807ee 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js index 3b608b2d02b9..5cd4ec178c5f 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json index 0071e72596ab..33cb925a1cc4 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json @@ -72,6 +72,4 @@ "2d", "two-dimensional" ] - - } - \ No newline at end of file + } \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js index 660ec9b4f522..74424ee9adb0 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. From c9b8af1b2a30b8d3f9df82ff74551b41980911f4 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:47:46 -0800 Subject: [PATCH 03/15] Apply suggestions from code review Signed-off-by: Athan --- .../assert/is-ragged-nested-array/README.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md index 2ca54cae3618..3f7c7adda0c9 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md @@ -32,13 +32,13 @@ var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); #### isRaggedNestedArray( value ) -Tests if a value is a ragged nested array. A ragged nested array is a nested array having inner dimensions of varying lengths. +Tests if a value is a ragged nested array. ```javascript -var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); // returns true -bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); // returns false ``` @@ -57,10 +57,10 @@ bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); ```javascript var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); -var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); // returns true -bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); // returns false bool = isRaggedNestedArray( 'beep' ); @@ -93,13 +93,6 @@ bool = isRaggedNestedArray( function noop() {} ); From 11eaa51590ea7f926ec334ff25aa3ee9c7d3b73a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:47:54 -0800 Subject: [PATCH 04/15] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md index 3f7c7adda0c9..a2a7b12b014e 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md @@ -1,4 +1,5 @@ # isRaggedNestedArray From 547a90edc44b8542e12c9dd69f10cc9c83cf2d73 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:48:41 -0800 Subject: [PATCH 06/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md index f65ff180d8e6..a10e4b2c50b6 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md @@ -100,13 +100,6 @@ bool = isRaggedNestedArray( function noop() {} ); From 4469ea1b7d16149c2f5617e2f0ee8856a5071cc5 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:50:38 -0800 Subject: [PATCH 07/15] Apply suggestions from code review Signed-off-by: Athan --- .../assert/is-ragged-nested-array/benchmark/benchmark.js | 4 +--- .../@stdlib/assert/is-ragged-nested-array/docs/repl.txt | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js index 23dacb4f464a..df03afcc9b1b 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js @@ -71,13 +71,11 @@ bench( pkg+'::non_ragged_array', function benchmark( b ) { bench( pkg+'::non_array', function benchmark( b ) { var bool; - var val; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - val = i; - bool = isRaggedNestedArray( val ); + bool = isRaggedNestedArray( i ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt index b861e542d4f3..442b2a845452 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -13,9 +13,9 @@ Examples -------- - > var bool = {{alias}}([ [1, 2, 3], [4, 5] ]) + > var bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5 ] ] ) true - > bool = {{alias}}([ [1, 2, 3], [4, 5, 6] ]) + > bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) false > bool = {{alias}}('beep') false From 39b883f6cf6bf45b0a0acaf7bea805d5484a0aaf Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:51:15 -0800 Subject: [PATCH 08/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt index 442b2a845452..6d3805d695a4 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -1,4 +1,4 @@ -{{alias}}(value) +{{alias}}( value ) Tests if a value is a ragged nested array. Parameters From 754ca0a787dd57ceb685ce990a187912b40b1b12 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:51:59 -0800 Subject: [PATCH 09/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/docs/repl.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt index 6d3805d695a4..2453e685a318 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -1,3 +1,4 @@ + {{alias}}( value ) Tests if a value is a ragged nested array. @@ -22,3 +23,4 @@ See Also -------- + From 7a4e95babeffd10b8976250b072c3f3af7ac64f3 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:53:35 -0800 Subject: [PATCH 10/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts index 37539589b108..e2a9505eb974 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts @@ -36,7 +36,7 @@ * var bool = isRaggedNestedArray( 'beep' ); * // returns false */ -declare function isRaggedNestedArray( value: any ): value is ArrayLike; +declare function isRaggedNestedArray( value: any ): boolean; // EXPORTS // From 6665a62af4a289af1501a28e3d446bd0174f7dc4 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:53:43 -0800 Subject: [PATCH 11/15] Apply suggestions from code review Signed-off-by: Athan --- .../assert/is-ragged-nested-array/docs/types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts index e2a9505eb974..6ffe421175bb 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts @@ -25,11 +25,11 @@ * @returns boolean indicating if a value is a ragged nested array * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); * // returns true * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * // returns false * * @example From c8673724d68954f7365159f0305fd197a8b8bd0d Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:54:17 -0800 Subject: [PATCH 12/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/docs/types/test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts index 5d6031981d86..746786325eb3 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts @@ -18,6 +18,7 @@ import isRaggedNestedArray = require( './index' ); + // TESTS // // The function returns a boolean... From fdc1f4cc4eb2a08b48966daae32320ce7ab0a197 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:54:42 -0800 Subject: [PATCH 13/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/docs/types/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts index 746786325eb3..cfb2df8d8a78 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts @@ -23,8 +23,8 @@ import isRaggedNestedArray = require( './index' ); // The function returns a boolean... { - isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); // $ExpectType boolean - isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); // $ExpectType boolean + isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); // $ExpectType boolean + isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); // $ExpectType boolean isRaggedNestedArray( 'beep' ); // $ExpectType boolean } From 2bebaf4a916a7c503fdd97a53ec92d44c932f640 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 24 Feb 2024 13:55:39 -0800 Subject: [PATCH 14/15] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/assert/is-ragged-nested-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md index a10e4b2c50b6..2889b561b41f 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md @@ -50,7 +50,7 @@ bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); ## Examples - + From 39586ed3d0907db4da20074b26dff66604793d2c Mon Sep 17 00:00:00 2001 From: Rutam Kathale Date: Sun, 25 Feb 2024 12:48:34 +0530 Subject: [PATCH 15/15] feat(@stdlib/assert): if applied, this commit will add the function isRaggedNestedArray' (Revision 2) Add support for checking if array-like objects are ragged and nested. Signed-off-by: Athan kgryte@gmail.com --- .../benchmark/benchmark.js | 4 +- .../is-ragged-nested-array/docs/repl.txt | 6 +- .../docs/types/index.d.ts | 4 +- .../is-ragged-nested-array/docs/types/test.ts | 4 +- .../is-ragged-nested-array/examples/index.js | 4 +- .../is-ragged-nested-array/lib/index.js | 4 +- .../assert/is-ragged-nested-array/lib/main.js | 18 +-- .../is-ragged-nested-array/package.json | 144 +++++++++--------- .../is-ragged-nested-array/test/test.js | 24 +-- 9 files changed, 105 insertions(+), 107 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js index 23dacb4f464a..12b4908bca97 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js @@ -34,7 +34,7 @@ bench( pkg+'::ragged_array', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = [ [i, i+1, i+2], [i-1, i-2] ]; + arr = [ [ i, i+1, i+2 ], [ i-1, i-2 ] ]; bool = isRaggedNestedArray( arr ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); @@ -55,7 +55,7 @@ bench( pkg+'::non_ragged_array', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = [ [i, i+1], [i-1, i] ]; + arr = [ [ i, i+1], [i-1, i ] ]; bool = isRaggedNestedArray( arr ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt index b861e542d4f3..7a98f824f1af 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt @@ -13,11 +13,11 @@ Examples -------- - > var bool = {{alias}}([ [1, 2, 3], [4, 5] ]) + > var bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5 ] ] ) true - > bool = {{alias}}([ [1, 2, 3], [4, 5, 6] ]) + > bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) false - > bool = {{alias}}('beep') + > bool = {{alias}}( 'beep' ) false See Also diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts index 37539589b108..a93e1d0a3629 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts @@ -25,11 +25,11 @@ * @returns boolean indicating if a value is a ragged nested array * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); * // returns true * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * // returns false * * @example diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts index 5d6031981d86..81de42c4bd30 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts @@ -22,8 +22,8 @@ import isRaggedNestedArray = require( './index' ); // The function returns a boolean... { - isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); // $ExpectType boolean - isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); // $ExpectType boolean + isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); // $ExpectType boolean + isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); // $ExpectType boolean isRaggedNestedArray( 'beep' ); // $ExpectType boolean } diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js index 29a62f4efa56..3fdb3440ea80 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js @@ -22,10 +22,10 @@ var isRaggedNestedArray = require( './../lib' ); -console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ) ); +console.log( isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ) ); // => true -console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ) ); +console.log( isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) ); // => false console.log( isRaggedNestedArray( 'beep' ) ); diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js index 082ae03807ee..df7394f175d5 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js @@ -26,10 +26,10 @@ * @example * var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); * -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); * // returns true * -* bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * // returns false * * bool = isRaggedNestedArray( 'beep' ); diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js index 5cd4ec178c5f..a94abfb93944 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js @@ -32,11 +32,11 @@ var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); * @returns {boolean} boolean indicating if a value is a ragged nested array * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); * // returns true * * @example -* var bool = isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ); +* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * // returns false * * @example @@ -44,19 +44,17 @@ var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); * // returns false */ function isRaggedNestedArray( value ) { - var len = -1; + var len; var i; - - if ( !isArrayLikeObject( value ) ) { + if ( !isArrayLikeObject( value ) || value.length < 2 ) { return false; } - for ( i = 0; i < value.length; i++ ) { - if ( !isArrayLikeObject( value[i] ) ) { + len = value[ 0 ].length; + for ( i = 1; i < value.length; i++ ) { + if ( !isArrayLikeObject( value[ i ] ) ) { return false; } - if ( len === -1 ) { - len = value[i].length; - } else if ( value[i].length !== len ) { + if ( value[ i ].length !== len ) { return true; } } diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json index 33cb925a1cc4..fc88beed62c3 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json @@ -1,75 +1,75 @@ { - "name": "@stdlib/assert/is-ragged-nested-array", - "version": "0.0.0", - "description": "Test if a value is a ragged nested array", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/assert/is-ragged-nested-array", + "version": "0.0.0", + "description": "Test if a value is a ragged nested array", + "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" - }, - "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": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "array", - "ragged", - "nested", - "is", - "israggednestedarray", - "object", - "obj", - "type", - "check", - "test", - "validate", - "isvalid", - "2d", - "two-dimensional" - ] - } \ No newline at end of file + } + ], + "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": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "array", + "ragged", + "nested", + "is", + "isarray", + "object", + "obj", + "type", + "check", + "test", + "validate", + "isvalid", + "2d", + "two-dimensional" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js index 74424ee9adb0..3ac8923767f3 100644 --- a/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable no-unused-vars */ - 'use strict'; // MODULES // @@ -39,13 +37,13 @@ tape( 'the function returns `true` if provided a ragged nested array', function var i; values = [ - [ [1, 2, 3], [4, 5] ], - [ [1, 2, 3], [4, 5, 6, 7] ], - [ [1], [2, 3], [4, 5, 6] ] + [ [ 1, 2, 3 ], [ 4, 5 ] ], + [ [ 1, 2, 3 ], [ 4, 5, 6, 7 ] ], + [ [ 1 ], [ 2, 3 ], [ 4, 5, 6 ] ] ]; for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isRaggedNestedArray( values[i] ), true, 'returns true when provided '+values[i] ); + t.strictEqual( isRaggedNestedArray(values[ i ]), true, 'returns true when provided ' + values[ i ] ); } t.end(); }); @@ -55,12 +53,12 @@ tape( 'the function returns `false` if provided a non-ragged nested array', func var i; values = [ - [ [1, 2, 3], [4, 5, 6] ], - [ [1, 2], [3, 4], [5, 6] ] + [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], + [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isRaggedNestedArray( values[i] ), false, 'returns false when provided '+values[i] ); + t.strictEqual( isRaggedNestedArray(values[ i ]), false, 'returns false when provided ' + values[ i ] ); } t.end(); }); @@ -78,12 +76,14 @@ tape( 'the function returns `false` if not provided a nested array', function te true, false, {}, - function boop( a, b, c ) {}, - [1, 2, 3] + [], + [ [ 1, 2, 3 ] ], + function noop() {}, + [ 1, 2, 3 ] ]; for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isRaggedNestedArray( values[i] ), false, 'returns false when provided '+values[i] ); + t.strictEqual( isRaggedNestedArray( values[ i ] ), false, 'returns false when provided ' + values[ i ] ); } t.end(); });