我在 node.js 中有以下模块:
var obj = {};
obj.prop1 = "value1";
obj.prop2 = "value2";
asyncFunction(function(data) {
obj.prop3 = data;
// I would like to do: obj.emit("completed");
});
module.exports = obj;
所以我可以像这样导入它:
var imp = require('./obj');
imp.on("completed", function() {
console.log("Hello!");
});
我该怎么做?