Skip to content

feat: add iter/while-each#1180

Merged
kgryte merged 22 commits intostdlib-js:developfrom
Jaysukh-409:iterWhile
Dec 16, 2023
Merged

feat: add iter/while-each#1180
kgryte merged 22 commits intostdlib-js:developfrom
Jaysukh-409:iterWhile

Conversation

@Jaysukh-409
Copy link
Copy Markdown
Member

@Jaysukh-409 Jaysukh-409 commented Dec 13, 2023

Resolves #810.

Description

What is the purpose of this pull request?

This pull request:

  • Create an iterator which, while a test condition is true, invokes a function for each iterated value before returning the iterated value.

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

I have added lib and examples for the whileEach iterator. Please review and provide feedback accordingly.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Dec 15, 2023
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/repl.txt Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/repl.txt Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/repl.txt Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/repl.txt Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/lib/main.js Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/lib/main.js
Comment thread lib/node_modules/@stdlib/iter/while-each/lib/main.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaysukh-409 Thanks for working on this! A few descriptions need to be updated, and this package still needs tests. For the latter, you can consult iter/for-each while borrowing some ideas from utils/while-each. Once resolved, this PR should be ready for merge.

Comment thread lib/node_modules/@stdlib/iter/while-each/README.md Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/iter/while-each/lib/main.js Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/lib/index.js Outdated
@Jaysukh-409
Copy link
Copy Markdown
Member Author

Please ignore changes made above. Due to some issues I got this trouble.

Comment thread lib/node_modules/@stdlib/iter/while-each/lib/main.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/iter/while-each/test/test.js Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/test/test.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaysukh-409 This is looking good! I think the only thing missing is benchmarks.

@kgryte
Copy link
Copy Markdown
Member

kgryte commented Dec 15, 2023

...and TypeScript declarations.

Jaysukh-409 and others added 2 commits December 16, 2023 11:33
Signed-off-by: Jaysukh Makvana <111515433+Jaysukh-409@users.noreply.github.com>
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/types/index.d.ts Outdated
Comment thread lib/node_modules/@stdlib/iter/while-each/docs/types/index.d.ts Outdated
Signed-off-by: Athan <kgryte@gmail.com>
*
* // ...
*/
declare function iterWhileEach( iterator: Iterator, predicate: Predicate, fcn: Callback, thisArg?: any ): Iterator;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve this type declaration, but we need to do this more generally for packages in iter/*, where we are not good about preserving type information. We can leave as is, for now, and address in a subsequent PR/commit.

Comment thread lib/node_modules/@stdlib/iter/while-each/docs/types/test.ts Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @Jaysukh-409!

@kgryte kgryte merged commit e31987a into stdlib-js:develop Dec 16, 2023
@Jaysukh-409 Jaysukh-409 deleted the iterWhile branch December 22, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Add @stdlib/iter/while-each

2 participants