Can this module work with other generator libraries - e.g. TJ's "co" module?
I noticed this channel library can work with simple promises without having to use generators.
And that your "spawn" function is fairly simple and designed around promises.
And I knew TJ's "co" module allows you to yield promises to his "co" function (similar to your "spawn"): https://www.npmjs.com/package/co
My question: Do you know (or do you think?) your module could work using that other "co" library in lieu of your "spawn" function? Is that part of the idea behind your design using Promises?
(I only ask because there's some other helper libraries that work together with "co" that seem convenient so I'd like to use it together with your library).
@darrencruse to be honest I do not know if this works with co as I have not tried it, but since it seems to claim to work with promises it should.
Promises were used in order to build upon concurrency primitives that were added to JS as there are already ton of libraries (co included) that provide convenient APIs to work with promises. In addition new versions of JS are likely to get more stuff like async await that will remove necessity of custom implementations of spawn.
Please keep in mind that this custom implementation of spawn will behave slightly different from co as it will try to read as much as possible in a single tick while co will read a chunk per tick.
Both approaches have pros and cons and it really depends on what the end goal is. I did wrote bunch about this here:
https://github.com/Gozala/streams/blob/master/Examples.md#coordinating-tasks
@darrencruse if you end up trying this out with co please let me know if that worked out or if you run into issues.