[RFC]: add `@stdlib/iter/cuany-by`
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
- [X] I have read and understood the Code of Conduct.
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with
RFC:.
Hii, I would like to start my open source contribution by solving this issue. Can anyone assign me to it?
@pra2107tham Thanks for volunteering to work on this. Please feel free to submit a PR implementing this feature.
Can you please tell me step by step way of solving this issue. i am not getting on how to do it?
@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.
Where is the predicate function in the code? i am not able to find it?
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.
I have made a PR, can you please check it up, all the test cases passes. Waiting for your approval
Sir idk which errors r coming as lint, I dont have any idea, can you please help me?
Hey @kgryte can i solve this issue since it is not solved for long time