Created
March 8, 2017 01:05
-
-
Save gerhardberger/efc8d64ec8c7f6d9efd19ccfe1108c13 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
const R = require('ramda') | |
const ccompose = (...fs) => { | |
let result | |
return function r (...args) { | |
if (!R.isNil(result)) args = [result, ...args] | |
result = fs.shift()(...args) | |
if (fs.length === 0) return result | |
return r | |
} | |
} | |
const mergeAndPick = ccompose(R.pick, R.merge) | |
console.log(mergeAndPick(['bar'], { foo: 'a', bar: 'b' })({ foo: 'x' })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment