-
Notifications
You must be signed in to change notification settings - Fork 35
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
forEach, index, repeaters, delays, every, batch, stack #13
Comments
|
As for function * batch (n) {
let buffer = [];
for ( const item of this ) {
buffer.push(item);
if ( buffer.length >= n ) {
yield buffer[Symbol.iterator]();
buffer = [];
}
}
}
[1,2,3,4]
::batch(2)
::map(to::partial(Array))
::to(Array)
// returns [[1, 2], [3, 4]] |
Yup, your code describes exactly what i imagined(isn't there a I don't understand your initial question; why should batch need to know which kind of collection it has to yield? - could it get more than one kind? EDIT: wrong button pressed... how can i remove the "closed" message? |
it's ok, no need to remove it :)
yes, nicely spotted! fixed - wonder where it went, I tried it before posting and it worked :D
IMO it shouldn't, should just be oblivious to collection types and unfold iterators only at user will instead. Just making sure I understood what you proposed. :) |
I imagine schedulers and eventsystems, for now i propose the following functions:
examples:
The text was updated successfully, but these errors were encountered: