Skip to content
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

Feature/iter cunone #2613

Closed

Conversation

ruthwikchikoti
Copy link

Resolves #2333.

Description

What is the purpose of this pull request?
This pull request:

  • Implements a new iterator function iterCuNone
  • Adds functionality to cumulatively test whether every iterated value is falsy
  • Enhances the stdlib iterator ecosystem

Related Issues

Does this pull request have any related issues?
This pull request:

Other

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

  • Takes an input iterator
  • Returns a new iterator that yields boolean values
  • Continues yielding true while all values are falsy
  • Yields false once a truthy value is encountered
  • Handles both iterable and non-iterable input iterators

Checklist

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


@stdlib-js/reviewers

Implement iterCuNone to create an iterator which cumulatively tests
whether every iterated value is falsy. This new function:

- Takes an input iterator
- Returns a new iterator that yields boolean values
- Continues yielding  while all values are falsy
- Yields  once a truthy value is encountered
- Handles both iterable and non-iterable input iterators

Includes:
- Main implementation
- TypeScript typings
- Tests
- Benchmarks
- Example usage
- Documentation

Closes stdlib-js#2333
## Usage

```javascript
var iterCuNone = require( '@stdlib/iter/cunone' );
Copy link
Member

Choose a reason for hiding this comment

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

This file is incomplete.

}
b.pass( 'benchmark finished' );
b.end();
});
Copy link
Member

Choose a reason for hiding this comment

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

Make sure you have EditorConfig setup as documented in the dev guides.

The returned iterator immediately returns `false` upon encountering a truthy
value, for all subsequent iterations.

If provided an iterator which does not return any iterated values, the
Copy link
Member

Choose a reason for hiding this comment

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

This isn't correct.

return v;
}
if ( v.value ) {
FLG = true;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is what we want. Once this is set, the iterator ends. We want the iterator to continue iterating so long as a source iterator has values.

Copy link
Member

Choose a reason for hiding this comment

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

Again, this is a cumulative iterator so the iterator should have the same length as the source iterator.

@@ -0,0 +1,85 @@
{
"name": "@stdlib/iter-cunone",
Copy link
Member

Choose a reason for hiding this comment

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

Package name is incorrect.

Copy link
Author

@ruthwikchikoti ruthwikchikoti Jul 17, 2024

Choose a reason for hiding this comment

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

@stdlib/iter/cunone
@kgryte

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that is correct. You can confirm this by examining all other packages in the main project repository. In short, package names should match the directory path.

"bugs": {
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

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

Dependencies and dev deps should not be present.


// MODULES //

var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
Copy link
Member

Choose a reason for hiding this comment

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

All these package names are incorrect. They should be names from the main project, not standalone pkg names. See other packages.

Copy link
Member

Choose a reason for hiding this comment

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

This applies here and elsewhere.

@@ -111,6 +111,76 @@ var objectKeys = require( '@stdlib/utils/keys' );
var kumaraswamy = require( '@stdlib/stats/base/dists/kumaraswamy' );

console.log( objectKeys( kumaraswamy ) );
// Create a Kumaraswamy distribution object
Copy link
Member

Choose a reason for hiding this comment

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

These changes should not be present in this PR.

@@ -22,3 +22,72 @@ var objectKeys = require( '@stdlib/utils/keys' );
var kumaraswamy = require( './../lib' );

console.log( objectKeys( kumaraswamy ) );
// Create a Kumaraswamy distribution object
Copy link
Member

Choose a reason for hiding this comment

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

These changes should not be present in this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Hey @kgryte, could you clarify if #1632 should be included here? Also, please review #1632 before I move on to #2613.

Copy link
Author

Choose a reason for hiding this comment

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

you are saying to remove #1632 right ? from this issue #2613

Copy link
Member

Choose a reason for hiding this comment

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

Correct. A PR should be focused on one thing. You are currently mixing both #1632 and #2613. This PR should only be concerned with #2613.

Copy link
Member

@kgryte kgryte Jul 17, 2024

Choose a reason for hiding this comment

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

You can simply undo the Kumaraswamy changes in this PR, and this PR can be judged on its own merits, irrespective of #1632.

@kgryte
Copy link
Member

kgryte commented Jul 17, 2024

@ruthwikchikoti Did you mean to close this? If you need to make changes, just do so on this PR.

@ruthwikchikoti ruthwikchikoti deleted the feature/iter-cunone branch July 17, 2024 09:32
@ruthwikchikoti ruthwikchikoti restored the feature/iter-cunone branch July 17, 2024 09:32
@ruthwikchikoti ruthwikchikoti deleted the feature/iter-cunone branch July 17, 2024 09:32
@ruthwikchikoti
Copy link
Author

@kgryte raising a new pr

ruthwikchikoti added a commit to ruthwikchikoti/stdlib that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add @stdlib/iter/cunone
2 participants