Last active
September 22, 2018 15:10
-
-
Save taverasmisael/4369a237970b296c77b0f9dd8e3cf0c8 to your computer and use it in GitHub Desktop.
A helper using Ramda to transform a URLSearch to an Object
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
const {prop, split, fromPairs, fromPairs, map, compose, tail} = R // from RamdaJS | |
export const URLSearchToObject = compose( | |
fromPairs, | |
map(split('=')), | |
compose( | |
split('&'), | |
tail | |
) | |
) | |
// Usage | |
URLSearchToObject('?some=param&any=other') // => ({some: 'param', any: 'other'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment