Skip to content

Instantly share code, notes, and snippets.

@gerhardberger
Created March 8, 2017 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerhardberger/efc8d64ec8c7f6d9efd19ccfe1108c13 to your computer and use it in GitHub Desktop.
Save gerhardberger/efc8d64ec8c7f6d9efd19ccfe1108c13 to your computer and use it in GitHub Desktop.
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