Skip to content
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 transduce transform. Resolves #212. #223

Merged
merged 4 commits into from
Feb 13, 2015
Merged

Add transduce transform. Resolves #212. #223

merged 4 commits into from
Feb 13, 2015

Conversation

vqvu
Copy link
Collaborator

@vqvu vqvu commented Feb 7, 2015

Docs adapted from @kevinbeaty's suggestion, but with the parts about resuming streams stripped out, since no transform resumes streams.

Error handling:

  • If step or result throws, then the transformation stops and the error (and nil) is pushed. This matches the behavior of reduce and scan.

@vqvu vqvu mentioned this pull request Feb 7, 2015
@svozza
Copy link
Collaborator

svozza commented Feb 10, 2015

Nice! Might be useful to have a test for a transducer that terminates early like takeWhile so we're testing the res.__transducers_reduced__ branch:

var isEven = function(n) { return n % 2 == 0; };

var xf = transducers.comp(transducers.takeWhile(function(n) { return n < 5; }), transducers.filter(isEven));

_([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).transduce(xf).toArray(function (xs) {
    test.same(xs, [2, 4])
});

@vqvu
Copy link
Collaborator Author

vqvu commented Feb 10, 2015

Done. The test just uses a take transducer.

@vqvu
Copy link
Collaborator Author

vqvu commented Feb 10, 2015

Note to self: Rebase onto master before merging.

@vqvu
Copy link
Collaborator Author

vqvu commented Feb 13, 2015

Since there's no more outstanding comments, I'll go ahead and merge this.

vqvu added a commit that referenced this pull request Feb 13, 2015
Add transduce transform. Resolves #212.
@vqvu vqvu merged commit 434d8ca into caolan:master Feb 13, 2015
@vqvu
Copy link
Collaborator Author

vqvu commented Feb 13, 2015

@jeromew Can you do a grunt release:minor with the latest master? @ibash also wanted a release.

@vqvu vqvu deleted the transduce branch February 13, 2015 03:29
@svozza
Copy link
Collaborator

svozza commented Feb 14, 2015

This is fantastic, fair play for all the work you've done lately not just on this particular PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants