facebook/idx

idx withDefault variant

cameron-chang opened this issue · 1 comments

I think it would be nice to add an additional export of the idx function which will allow us to pass in a default value.

Since idx has its own type, it would be quite difficult to create a wrapper around idx without breaking the current type signature.

I propose an API that looks like this:

idxOr('DEFAULT VALUE', data, data => data.path.name);

Similar to ramda's pathOr function http://ramdajs.com/docs/#pathOr

This was proposed in #5 (which contains an explanation for why we don't want to extend idx beyond what is currently being proposed for the JavaScript language.