Last active
May 18, 2017 07:56
-
-
Save bolasblack/d3784504345c0f4ba1a753b37e669877 to your computer and use it in GitHub Desktop.
[dot chain syntax for ramda.js]
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
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