Hm... I hadn't though about this, and it's interesting to me. The main reason to use chainable methods was to mimic arrays, as extending array functions to generators is how this idea started.
For what you propose,
how would you discriminate between sync and async iterators?
what would the pipeline stages receive and return?
The main reason to use chainable methods was to mimic arrays, as extending array functions to generators is how this idea started.
Fair enough, familiarity is always a bonus :)
how would you discriminate between sync and async iterators?
Either take MojiScript's idea and make all pipelines async anyway, or provide a pipeAsync function that would be equivalent to your .async().
what would the pipeline stages receive and return?
I'd say there wouldn't be any intermediate stages. The pipe would be created with a list of functions, and then it would be given and array and apply all operations to each element of the array at once, effectively iterating over the array only once.
But I think that's more a matter of API ergonomics than actual differences in behaviour, you can probably achieve similar results either way.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hm... I hadn't though about this, and it's interesting to me. The main reason to use chainable methods was to mimic arrays, as extending array functions to generators is how this idea started.
For what you propose,
Fair enough, familiarity is always a bonus :)
Either take MojiScript's idea and make all pipelines async anyway, or provide a
pipeAsync
function that would be equivalent to your.async()
.I'd say there wouldn't be any intermediate stages. The pipe would be created with a list of functions, and then it would be given and array and apply all operations to each element of the array at once, effectively iterating over the array only once.
But I think that's more a matter of API ergonomics than actual differences in behaviour, you can probably achieve similar results either way.