模块参数覆盖函数参数
我是从module.exports
我的生成器方法,但它获取module
arguments
数组不是被调用的函数。
const Promise = require('bluebird'); const inc = Promise.coroutine(function* (model, condition, fields, options = {}) {}); module.exports = { inc: (model, condition, fields, options = {}) => { //reveiving all the arguments fine return inc.apply(null, arguments); //but "arguments" array contains the values of "module", not the function } };
arguments
数组:
0 - require function 1 - Module 2 - file path 3 - directory path
箭头函数不绑定参数对象 。
它应该是:
module.exports = { inc: (...args) => inc(...args) };
除非直接导出导致function上下文的问题,它可以是:
module.exports = { inc };