-
Notifications
You must be signed in to change notification settings - Fork 147
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
Add ap
method and a simple test
#643
Conversation
Still needs appropriate tests. |
lib/index.js
Outdated
return this.map(function (f) { | ||
return m.fork().map(f); | ||
}) | ||
.parallel(Infinity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically I would use .merge()
here because of m.fork()
, but I feel like that is taking too much liberty with users' code since order of results is not guaranteed. I think that also violates the composition
specification because the results will not necessarily be the same if the function or values are asynchronous (re: events).
First of all, thanks for picking this up. I have a few comments.
It's definitely possible to implement even this version of I know that #114 says It turns out there are more than one implementation that will satisfy the fantasy-land spec.
(1) is slightly better than (2), since the stream being interleaved needs to be saved, and the stream of functions is likely to be shorter, it slightly more optimal to interleave the functions. That said, they both have the same limitation of throwing away (some) timing data. In contrast, (3) doesn't. To illustrate, consider the streams (the numbers in the first row are seconds since the start).
The outputs of the implementations look like this
Notice the bunchings at
So I would say implementation 3 has going it for it the following things
Given the above, I would like to implement |
I'm still going over the differences in implementations, but I think I should note that using I've seen the If
You can see that the bunching becomes less pronounced and the timing is (more) preserved. This feels to me more like a half-step between Impl 2 and Impl 3 where all functions are applied to the most recent values. I will take a stab at implementing something more like 3 so I can get a better perspective on the differences in the use cases I am familiar with. Also, thanks so much for your thoughtful and informative response above! |
Just for reference, my typical use case for this is to represent closures across a set of possible permutations of inputs. A closure could be operations on a database and the permutations could be the possible input values and possible database connection configurations. In these cases
In these cases I expect
|
Here's a rough alternative implementation that maybe you could weigh in on for comparison. It appears to me to behave similarly to
The timing and results:
|
Sorry for letting this sleep here for so long. @vqvu I'd be interested in your opinion on this implementation using higher-level highland functionality as well as what tests would be necessary to really prove this out. |
Thanks for picking this back up! LGTM on the implementation. And sorry for not following through on this. It looks like I was the one who dropped the ball. Re: tests
Other than that, your tests look fine to me. |
Looks like a transitive dependency of ours no longer works with node 0.10, and that's why Travis is complaining. I've locked nodeunit to version 0.11.2 as a workaround. |
Resolved #643 (comment) in 98f1b7d and 0fe6fec |
This was breaking a build on an older Node version. https://travis-ci.org/caolan/highland/jobs/445755627
Also, I'm unsure what to update in https://github.com/caolan/highland/blob/master/CHANGELOG.md Does this go under a |
This will go under a new 3.0.0-beta.7 heading. It won't appear in 2.x unless someone backports it to the 2.x branch, and I'm trying to keep new transforms from being added in 2.x (bugfix-only for that branch). |
I've addressed the requested changes. I also updated CHANGELOG.md to include the addition of the I can revert these if you have a different method for making these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the CHANGELOG.md
. You don't need to update package.json
since our release script does this automatically.
This is a rehash of an unfinished part of #114. The implementation and examples there only work if all of the streams are synchronous.
I would still like to add some tests to validate the functionality.
per https://github.com/fantasyland/fantasy-land#apply