我该如何传送?
R.keys(obj)返回一个列表R.head应该获得列表的第一项我想念的是什么?
const obj = {f: "hi"}
const keysList = R.keys(obj);
const head = R.head(keysList);
const myPipe = R.pipe(keysList , head ) //?
R.pipe需要一个函数列表,并返回一个新函数。调用该函数时,传递给该函数的所有参数都将传递给管道中的第一个函数,第一个函数的结果将传递给下一个,依此类推。]
在您的情况下,您尝试创建如下所示的函数:
o => R.head(R.keys(o))
相当于:
R.pipe(R.keys, R.head)
示例:
const obj = {f: "hi"} const myPipe = R.pipe(R.keys, R.head) const result = myPipe(obj) console.log(result)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.js"></script>