Skip to content

Instantly share code, notes, and snippets.

@bolasblack
Last active May 18, 2017 07:56
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 bolasblack/d3784504345c0f4ba1a753b37e669877 to your computer and use it in GitHub Desktop.
Save bolasblack/d3784504345c0f4ba1a753b37e669877 to your computer and use it in GitHub Desktop.
[dot chain syntax for ramda.js]
import R from 'ramda'
class CR {
constructor(fn) {
this.runCR = (fn || R.identity)
}
}
R.keys(R).forEach(method => {
CR.prototype[method] = function() {
var rfn = arguments.length ? R[method].apply(null, arguments) : R[method]
return new CR(R.pipe(this.runCR, rfn))
}
})
const cR = fn => new CR(fn)
console.log(cR().omit(['Account']).keys().map(tableName => {
console.log('tableName', tableName)
return tableName + '1'
}).runCR({Account: 1, Todo: 2, Pomo: 3}))
/* output:
tableName Todo
tableName Pomo
[ 'Todo1', 'Pomo1' ]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment