Created
May 19, 2018 04:09
-
-
Save krainboltgreene/4a63dcedae4ce53fbc7a3e0c0eb8449b to your computer and use it in GitHub Desktop.
This file contains 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
// KeyChain:: Array<mixed> | |
// Before:: mixed | |
// After:: Mixed | |
// Replacements:: Map<Before, After> | |
// patchTree:: (Map<KeyChain, Replacements>) => Object => Object |
This file contains 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
export default patchTree( | |
new Map([ | |
[ | |
["id"], | |
["me", current_account.id], | |
], | |
[ | |
["data", "id"], | |
new Map([ | |
["me", current_account.id], | |
]), | |
], | |
[ | |
["data", "relationships", "billing-information", "data", "id"], | |
new Map([ | |
["latest", current_account.billing_informations.last.id], | |
["current", current_cart.billing_information.id], | |
]), | |
], | |
]) | |
) |
This file contains 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
import shortcutReplacement from "patchtree-2" | |
shortcutReplacement({ | |
id: "me", | |
data: { | |
attributes: { | |
name: "Kurtis Rainbolt-Greene" | |
}, | |
relationships: { | |
"billing-informations": { | |
data: { | |
id: "current" | |
} | |
} | |
} | |
} | |
}) |
This file contains 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
{ | |
id: "1", | |
data: { | |
attributes: { | |
name: "Kurtis Rainbolt-Greene" | |
}, | |
relationships: { | |
"billing-informations": { | |
data: { | |
id: "2" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment