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 _.transform method #2075

Closed
wants to merge 2 commits into from
Closed

Conversation

jridgewell
Copy link
Collaborator

Another undiscussed removal.

I’m not so hot on the Ctor conditional, or early breaking. But I want this method.

Re: #1901
Re: #2061, 4f771e0

@megawac
Copy link
Collaborator

megawac commented Feb 20, 2015

👍

@jridgewell jridgewell changed the title Transform Add _.transform method Feb 20, 2015
@jridgewell
Copy link
Collaborator Author

Whoops, left in the _.create commit. Rebased and removed it.

@jashkenas
Copy link
Owner

I think that the API is currently too magical — and not something we're going to want to end up supporting long term.

@jamiebuilds
Copy link
Contributor

What would make it less magical?

@jgonggrijp
Copy link
Collaborator

Really, this does not belong in a functional library. The only reason for having this instead of _.reduce in the first place is the option to break out of the loop, which in turn requires modifying the accumulator in place, but both of those things are procedural and completely against the conventions of the other collection functions. Besides, I don't see why one would want to transform an object only partially.

"Magical" probably referred to the attempt to conjure an appropriate accumulator out of thin air when none is provided. The if/else tree to support this will grow out of proportions over time and any attempt to draw a line on that will be arbitrary. Indeed, this has grown into a cluster of arbitrary special cases in the Lodash implementation.

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.

5 participants