Created
April 20, 2017 04:46
-
-
Save ahdinosaur/f35617bd4c9e2d46362d87197b909c19 to your computer and use it in GitHub Desktop.
fp
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
const toConstantCase = pipe( | |
map(toUpper), | |
join('_') | |
) | |
function pipe (...fns) { | |
return (value) => { | |
return fns.reduce((sofar, nextFn) { | |
return nextFn(sofar) | |
}, value) | |
} | |
} | |
function mapToUpper (items) { | |
return items.map(str => str.toUpperCase()) | |
} | |
function joinItems (items) { | |
return items.join('_') | |
} | |
function toConstantCase (path) { | |
return path | |
.map(str => str.toUpperCase()) | |
.join('_') | |
} | |
const TYPE = toConstantCase(['feathers', 'dogs', 'create']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment