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 support for objects in the f function #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NicholasAntonov
Copy link

Often times, users might have a map as an object, and want to access a property on that object based on some other property in the data. This pr allows that to be easily composed using the f function. Through function composition, now users can chain accessing properties, to feeding those properties into other objects using a convenient shorthand.

@gka
Copy link
Owner

gka commented Nov 1, 2017

I think I like this one. But I do have the feeling that I've added this to d3.f already at some point, so better to check with @1wheel to see if there was any reason to not include objects.

@gka
Copy link
Owner

gka commented Nov 1, 2017

ah I see, we added f.objToFn for this use case. just wrap your object inside this function and it should work

test.equal(ƒ(ƒ.objToFn({foo: 'bar'}))('foo'), 'bar');

https://github.com/gka/d3-jetpack/blob/master/src/f.js#L23-L29

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