Reduce code complexity
This commit is contained in:
parent
8d280e157c
commit
465eca0c5e
@ -66,17 +66,9 @@ const methods = ['getMe', 'sendMessage', 'forwardMessage', 'sendPhoto',
|
|||||||
methods.forEach(method => {
|
methods.forEach(method => {
|
||||||
API.prototype[method] = function (data) { //eslint-disable-line
|
API.prototype[method] = function (data) { //eslint-disable-line
|
||||||
// implementation taken from https://github.com/yagop/node-telegram-bot-api/issues/192#issuecomment-249488807
|
// implementation taken from https://github.com/yagop/node-telegram-bot-api/issues/192#issuecomment-249488807
|
||||||
let resolve;
|
return new Promise((resolve, reject) => {
|
||||||
let reject;
|
|
||||||
|
|
||||||
const promise = new Promise((_resolve, _reject) => {
|
|
||||||
resolve = _resolve;
|
|
||||||
reject = _reject;
|
|
||||||
});
|
|
||||||
|
|
||||||
this._queue.push({ method, data, resolve, reject });
|
this._queue.push({ method, data, resolve, reject });
|
||||||
process.nextTick(this._runQueue.bind(this));
|
process.nextTick(this._runQueue.bind(this));
|
||||||
|
});
|
||||||
return promise;
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user