d3-jetpack
d3-jetpack copied to clipboard
Add support for objects in the f function
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.
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.
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