【发布时间】:2016-03-04 04:46:09
【问题描述】:
我想将当前上下文或属性传递给async.waterfall 中的函数。如何:
- 通过
this - 一个属性(这里是
options对象)
这是我已经拥有的:
var _authenticate = function (cbAsync) {
var licenseId = options.licenseId; //options is undefined
};
module.exports = new Command('createOrga')
.description('creates an organization')
.option('-f, --file <file>', 'the structure file including full path')
.action(function (options) {
options.confirm = options.confirm || true; // No confirmation needed!
options.organizationUUID = (uuid.v4()).toUpperCase();
options.licenseId = (uuid.v4()).toUpperCase();
//How to pass options object to _authenticate function????
async.waterfall([ _authenticate ], function(err) {
if ( err ) {
console.warn('Error in creating new organization: ',err);
}
else {
console.info('Successfully created new organization: ' + organizationUUID);
}
});
}
}
【问题讨论】:
-
你想通过哪个
this? -
上面贴的代码只是一个子集。问题是
.action中的上下文是否如this可以传递给_authenticate?
标签: javascript node.js node-modules async.js