我从module.exports
引用了我的生成器方法,但它的arguments
数组module
不是被调用的函数。
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
答案 0 :(得分:1)
Arrow functions do not bind an arguments object
应该是:
module.exports = {
inc: (...args) => inc(...args)
};
除非直接导出它导致函数上下文出现问题,否则它可能只是:
module.exports = {
inc
};