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

[RFC]: add @stdlib/iter/cuany-by #2335

Open
3 tasks done
kgryte opened this issue Jun 8, 2024 · 9 comments · May be fixed by #2837
Open
3 tasks done

[RFC]: add @stdlib/iter/cuany-by #2335

kgryte opened this issue Jun 8, 2024 · 9 comments · May be fixed by #2837
Assignees
Labels
Accepted RFC feature request which has been accepted. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Issue or pull request for adding a new feature. Good First Issue A good first issue for new contributors! JavaScript Issue involves or relates to JavaScript. priority: Normal Normal priority concern or feature request. RFC Request for comments. Feature requests and proposed changes.

Comments

@kgryte
Copy link
Member

kgryte commented Jun 8, 2024

Description

This RFC proposes adding the package @stdlib/iter/cuany-by, which cumulatively tests whether at least one iterated value passes a test implemented by a predicate function. The returned iterator should be a transform iterator, continuing to iterate while source iterator values are available.

var array2iterator = require( '@stdlib/array/to-iterator' );

function isPositive( value ) {
	return ( value > 0 );
}

var arr = array2iterator( [ 0, 0, 0, 1, 0 ] );

var it = iterCuAnyBy( arr, isPositive );

var v = it.next().value;
// returns false

v = it.next().value;
// returns false

v = it.next().value;
// returns false

v = it.next().value;
// returns true

v = it.next().value;
// returns true

var bool = it.next().done;
// returns true

The predicate function should be provided two arguments:

  • value: the iterated value.
  • index: iteration index (zero-based).

Related Issues

No.

Questions

No.

Other

  • See also @stdlib/iter/any-by

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@kgryte kgryte added RFC Request for comments. Feature requests and proposed changes. Feature Issue or pull request for adding a new feature. Accepted RFC feature request which has been accepted. Good First Issue A good first issue for new contributors! priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. labels Jun 8, 2024
@pra2107tham
Copy link

Hii, I would like to start my open source contribution by solving this issue. Can anyone assign me to it?

@kgryte
Copy link
Member Author

kgryte commented Jul 8, 2024

@pra2107tham Thanks for volunteering to work on this. Please feel free to submit a PR implementing this feature.

@pra2107tham
Copy link

Can you please tell me step by step way of solving this issue. i am not getting on how to do it?

@kgryte
Copy link
Member Author

kgryte commented Jul 9, 2024

@pra2107tham I suggest copying the package iter/cuany to iter/cuany-by and then refactoring to support a callback argument. The signature of the main export should match iter/any-by, but the behavior should be similar to cuany.

@pra2107tham
Copy link

Where is the predicate function in the code? i am not able to find it?

@kgryte
Copy link
Member Author

kgryte commented Jul 10, 2024

There isn't a predicate function in iter/cuany. The purpose of this RFC is to create a separate package exposing a transform iterator which is similiar to cuany but provides an implementation supporting a predicate function. An example of a sink iterator which supports a predicate function is any-by. To implement this package, you need to borrow the interface of any-by and extend the behavior of cuany.

@pra2107tham
Copy link

I have made a PR, can you please check it up, all the test cases passes. Waiting for your approval

@pra2107tham
Copy link

Sir idk which errors r coming as lint, I dont have any idea, can you please help me?

@gururaj1512
Copy link

Hey @kgryte can i solve this issue since it is not solved for long time

@gururaj1512 gururaj1512 linked a pull request Aug 26, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted RFC feature request which has been accepted. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Issue or pull request for adding a new feature. Good First Issue A good first issue for new contributors! JavaScript Issue involves or relates to JavaScript. priority: Normal Normal priority concern or feature request. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants