remove leading underscore, fix next call in mongosave
This commit is contained in:
39
dist/callchain.js
vendored
39
dist/callchain.js
vendored
@ -6,53 +6,68 @@ class LastChainItem {
|
||||
begin() {
|
||||
}
|
||||
send(message) {
|
||||
log.info(`Last chain item, final result ${message}`);
|
||||
log.info(`Last chain item, final result ${JSON.stringify(message)}`);
|
||||
}
|
||||
}
|
||||
let lastChainItem = new LastChainItem();
|
||||
class AChainItem extends events.EventEmitter {
|
||||
constructor(label) {
|
||||
super();
|
||||
this._label = label;
|
||||
this._next = lastChainItem;
|
||||
this.label = label;
|
||||
this.next = lastChainItem;
|
||||
}
|
||||
toString() {
|
||||
return `<${this._label}>`;
|
||||
return `<${this.label}>`;
|
||||
}
|
||||
registerNext(next) {
|
||||
this._next = next;
|
||||
this.next = next;
|
||||
}
|
||||
send(message) {
|
||||
this.emit('yourturn', message);
|
||||
}
|
||||
}
|
||||
exports.AChainItem = AChainItem;
|
||||
class AAsyncBaseChainItem extends AChainItem {
|
||||
constructor(label) {
|
||||
super(label);
|
||||
}
|
||||
begin() {
|
||||
if (this.next != null) {
|
||||
this.next.begin();
|
||||
}
|
||||
this.addListener('yourturn', (message) => {
|
||||
log.info(`Calling ${this.toString()}`);
|
||||
this.func(message, this.next.send);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.AAsyncBaseChainItem = AAsyncBaseChainItem;
|
||||
class ABaseChainItem extends AChainItem {
|
||||
constructor(label) {
|
||||
super(label);
|
||||
}
|
||||
begin() {
|
||||
if (this._next != null) {
|
||||
this._next.begin();
|
||||
if (this.next != null) {
|
||||
this.next.begin();
|
||||
}
|
||||
this.addListener('yourturn', (message) => {
|
||||
log.info(`Calling ${this.toString()}`);
|
||||
let result = this.func(message);
|
||||
this._next.send(result);
|
||||
this.next.send(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ABaseChainItem = ABaseChainItem;
|
||||
class ChainItem extends ABaseChainItem {
|
||||
toString() {
|
||||
let funcName = (this._chainItemFunc.name === "") ? "lambda" : this._chainItemFunc.name;
|
||||
return `<${funcName}, ${this._label}>`;
|
||||
let funcName = (this.chainItemFunc.name === "") ? "lambda" : this.chainItemFunc.name;
|
||||
return `<${funcName}, ${this.label}>`;
|
||||
}
|
||||
registerFunc(func) {
|
||||
this._chainItemFunc = func;
|
||||
this.chainItemFunc = func;
|
||||
}
|
||||
func(message) {
|
||||
return this._chainItemFunc(message);
|
||||
return this.chainItemFunc(message);
|
||||
}
|
||||
}
|
||||
exports.ChainItem = ChainItem;
|
||||
|
Reference in New Issue
Block a user