2017-10-05 75 views
0

是否可以在单个语句中简化此表达式?部分应用于ramda

const _readFile = R.curry(fs.readFile); 
const _readFile2 = _readFile(R.__, 'UTF-8', R.__); 
+0

不是那么好你的意思是'常量_readFile2 = R.curry(fs.readFile) (R .__,'UTF-8',R .__)'? – kay

+0

对不起,我不清楚。像 https://github.com/plaid/async-problem/blob/0ea31b01eabf9a2cdb22bad112aee37e96325524/common/read-file-callback.js –

+1

@kay:那第二个'R .__'不应该是需要的。作为最后的论据是没有意义的。 –

回答

2

你能做到这一点,但它

const _readFile = compose(apply(__, [__, 'UTF-8', __]), curry)(readfile) 

我个人学习向

const _readFile = curry((file, cb) => readfile(file, 'UTF-8', cb))