-
-
Notifications
You must be signed in to change notification settings - Fork 836
feat: add assert/is-ragged-nested-array
#1368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add assert/is-ragged-nested-array
#1368
Conversation
…isRaggedNestedArray' (assert/is-ragged-nested-array) Add support for checking if array-like objects are ragged and nested. Fixes: stdlib-js#1347 Issue Link: stdlib-js#1347
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hi there! 👋
And thank you for opening your first pull request! We will review it shortly. 🏃 💨
assert/is-ragged-nested-array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address following suggestion, also run the tests, benchmarks prior to pushing the changes.
lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/lib/main.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/package.json
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/test/test.js
Outdated
Show resolved
Hide resolved
…sRaggedNestedArray' (Revision 1) Add support for checking if array-like objects are ragged and nested. Signed-off-by: Pranavchiku goswami.4@iitj.ac.in
Hello, I have modified the files, marked the suggestions as done, and pushed the commit with the changes! Please do let me know if there are any further changes necessary. |
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/assert/is-ragged-nested-array/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/repl.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/assert/is-ragged-nested-array/docs/types/test.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5] ] ) ); | ||
// => true | ||
|
||
console.log( isRaggedNestedArray( [ [1, 2, 3], [4, 5, 6] ] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ] ] ) ); | |
// => true | |
console.log( isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) ); |
Here and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion @kgryte! Just to confirm, you mean adding a leading and trailing whitespace in array initializations in all files in the package not just this one right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
lib/node_modules/@stdlib/assert/is-ragged-nested-array/README.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
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 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ) { | |
var len; | |
var i; | |
if ( !isArrayLikeObject( value ) || value.length < 2 ) { | |
return false; | |
} | |
len = value[ 0 ].length; | |
for ( i = 1; i < value.length; i++ ) { | |
if ( !isArrayLikeObject( value[ i ] ) ) { | |
return false; | |
} | |
if ( value[ i ].length !== len ) { |
Empty and single element arrays are not ragged. You can avoid additional branching logic by caching the length of the first array.
@@ -0,0 +1,75 @@ | |||
{ | |||
"name": "@stdlib/assert/is-ragged-nested-array", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation in this file is off.
"2d", | ||
"two-dimensional" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline.
"ragged", | ||
"nested", | ||
"is", | ||
"israggednestedarray", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"israggednestedarray", | |
"isarray", |
* limitations under the License. | ||
*/ | ||
|
||
/* eslint-disable no-unused-vars */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test files should never have unused variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, thanks! Also, just noticed that the package 'is-array-like-object', had this line in the test.js file.
/* eslint-disable object-curly-newline, no-unused-vars */
I'm not sure if it's the expected behavior there, but in case it isn't, just letting you know!
Edit: So, just noticed that this is used 20 times in 9 files in node_modules/@StdLib
var i; | ||
|
||
values = [ | ||
[ [1, 2, 3], [4, 5] ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing.
false, | ||
{}, | ||
function boop( a, b, c ) {}, | ||
[1, 2, 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty array and [ [ 1, 2, 3 ] ]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @performant23. This is shaping up. So long as the comments are addressed, this is on track for being merged.
…sRaggedNestedArray' (Revision 2) Add support for checking if array-like objects are ragged and nested. Signed-off-by: Athan kgryte@gmail.com
…ttps://github.com/performant23/stdlib into feature/add-@stdlib/assert/is-ragged-nested-array
Hey everyone, I have modified the files and pushed the commit with the changes! Please do let me know if there are any further changes necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the requested changes and your contribution, @performant23! This looks good to me; will merge shortly.
Add support for checking if array-like objects are ragged and nested.
Resolves #1347
Description
This pull request:
Related Issues
This pull request:
@stdlib/assert/is-ragged-nested-array
#1347Questions
No.
Other
The test results when applied on the functionality (benchmarks, examples, tests) can be found here - https://drive.google.com/drive/folders/1AomH4BL-sKkQCO6lhFU5BUelUW3wZp4f?usp=sharing
Checklist
@stdlib-js/reviewers