{"size": 826, "ext": "js", "max_stars_repo_path": "package/es/funer/partialer.js", "max_stars_repo_name": "hjqcl316602/app-trade-admin", "max_stars_repo_stars_event_min_datetime": "2020-11-22T12:54:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-22T12:54:22.000Z", "max_issues_repo_path": "package/es/funer/partialer.js", "max_issues_repo_name": "hjqcl316602/app-trade", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "package/es/funer/partialer.js", "max_forks_repo_name": "hjqcl316602/app-trade", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.6666666667, "max_line_length": 88, "alphanum_fraction": 0.5617433414}
/**
 * @name 偏函數
 * @msg 
 * 创建一个调用另一部分参数或变量已经预置的函数
 * 可以先进行一些参数的设置
 * @param { fn }  [ function ]
 * @param {...args }
 * @return [ function ]
 */

export default function partialer(fn, ...args) {
  if (typeof fn !== "function") throw new Error("The first argument must be function.");
  return function(...rest) {
    return fn.apply(this, [...args, ...rest]);
  };
}

// let cur = partial(function(a,b){
//   return a + b
// },1)

// console.log(cur(2))

// 偏函数的应用场景

// function isType(type) {
//   return function(value) {
//     return (
//       Object.prototype.toString
//         .call(value)
//         .slice(8, -1)
//         .toLowerCase() === type
//     );
//   };
// }

// let isString = isType('string')
// let isFunction = isType('function')
// let isNumber = isType('number')

// console.log(isString(''))
