Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

idx withDefault variant #32

Closed
cameron-chang opened this issue Sep 5, 2017 · 1 comment
Closed

idx withDefault variant #32

cameron-chang opened this issue Sep 5, 2017 · 1 comment

Comments

@cameron-chang
Copy link

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

@yungsters
Copy link
Contributor

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.

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

No branches or pull requests

2 participants