Add unsetPath helper function#323
Merged
Merged
Conversation
karthikiyengar
approved these changes
Oct 8, 2018
| Used to remove a property or index on a deeply nested `Object`/`Array`. | ||
| `unsetPath` is will return a new instance with the property or index removed. | ||
|
|
||
| The provided path can be a mixture of either `Integer`s or `String`s to allow |
Collaborator
There was a problem hiding this comment.
Looks like we've taken a different direction from Ramda here?
dissocPath([1], { 1: {} } ) // []
unsetPath([1], { 1: {} } ) // { '1': {} }
Owner
Author
There was a problem hiding this comment.
Yeppers, this is by design.
Notice how ramda takes an object and transforms it into an Array, that seemed odd to me.
So unsetPath does nothing to the Object, because Strings are used as props on an Object and it cannot find an Integer key on the Object.
Owner
Author
There was a problem hiding this comment.
But this is intentional behavior.
Collaborator
There was a problem hiding this comment.
Makes sense. Thanks for the explanation.
Owner
Author
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A path a little less traveled
This PR adds a function that provides the functionality from the
dissocPathfunction provided byramda. This was motivated by the documentation on the meiosis project from @foxdonut.This PR signals a change to some of the existing functions to match this new naming convention for dealing with functions like:
propandpropPath. The following functions will be addressed in the next breaking change release, although they will be deprecated and their original names will still be available until we hit1.0.0:Maybe/propPath->Maybe/getPathMaybe/prop->Maybe/getProphelpers/assoc->helpers/setProp(will work withArrayas well)helpers/dissoc->helpers/unsetProp(will work withArrayas well)helpers/propOr->helpers/getPropOrhelpers/propPathOr->helpers/getPathOr