Passing multiple arguments and result of last function through pipe

后端 未结 2 1175
说谎
说谎 2021-01-27 23:37

I\'m building a pipe with Ramda.js which accepts three arguments. The first function needs those three arguments, and it\'s result is used in the second function. However, the s

2条回答
  •  旧时难觅i
    2021-01-28 00:39

    I think the simplest thing here is to not bother with Ramda's pipe function, which is not designed to handle such case, and just write it manually:

    const func1 = (a, b, c) => `func1 (${a}, ${b}, ${c})`
    const func2 = (a, d) => `func2 (${a}, ${d})`
    
    const func3 = (a, b, c) => func2 (func1 (a, b, c), a)
    
    console .log (func3 ('a', 'b', 'c'))

    Ramda has recently been considering a way to make this easier for longer pipelines; even with that, though, the above is probably simpler for just a few functions.

提交回复
热议问题