相关疑难解决方法(0)

如何使用Lodash流程了解咖喱和功能组成?

import {flow, curry} from 'lodash';

const add = (a, b) => a + b;

const square = n => n * n;

const tap = curry((interceptor, n) => {
    interceptor(n);
    return n;
});

const trace2 = curry((message, n) => {
    return tap((n) => console.log(`${message} is  ${n}`), n);
});

const trace = label => {
    return tap(x => console.log(`== ${ label }:  ${ x }`));
};


const addSquare = flow([add, trace('after add'), square]);
console.log(addSquare(3, 1));
Run Code Online (Sandbox Code Playgroud)

我开始写跟踪2认为跟踪不起作用,因为"如何挖掘可能知道n或x什么?".

但跟踪确实有效,我不明白它如何能够"注入"来自流量的x进入点击呼叫.任何解释将不胜感激:)

functional-programming lodash

9
推荐指数
1
解决办法
1680
查看次数

标签 统计

functional-programming ×1

lodash ×1