Curry

function curry(fn, ...args) {
  const length = fn.length
  let lists = args || []
  let listLen
  return function (..._args) {
    lists = [...lists, ..._args]
    listLen = lists.length
    if (listLen < length) {
      const that = lists
      lists = []
      return curry(fn, ...that)
    } else if (listLen === length) {
      const that = lists
      lists = []
      return fn.apply(this, that)
    }
  }
}
原文地址:https://www.cnblogs.com/chenmingxu/p/13182350.html