stdlib-js / stdlib

✨ Standard library for JavaScript and Node.js. ✨
https://stdlib.io
Apache License 2.0
4.28k stars 436 forks source link

[RFC]: add `@stdlib/iter/cusome` #2334

Closed kgryte closed 1 month ago

kgryte commented 2 months ago

Description

This RFC proposes adding the package @stdlib/iter/cusome, which cumulatively tests whether at least n iterated values are truthy. The function should be a transform iterator, continuing to iterate while source iterator values are available.

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

var arr = array2iterator( [ false, false, false, true, true ] );

var it = iterCuSome( arr, 2 );

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

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

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

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

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

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

Related Issues

No.

Questions

No.

Other

Checklist

TheNourhan commented 1 month ago

Can you assign this to me please?

kgryte commented 1 month ago

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