1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Pass through eslint --fix

This commit is contained in:
Kegan Dougal
2017-01-13 10:49:32 +00:00
parent 97e421306b
commit 7ed65407e6
60 changed files with 3249 additions and 3072 deletions

View File

@@ -19,10 +19,10 @@ limitations under the License.
* of requests.
* @module scheduler
*/
var utils = require("./utils");
var q = require("q");
let utils = require("./utils");
let q = require("q");
var DEBUG = false; // set true to enable console logging.
let DEBUG = false; // set true to enable console logging.
/**
* Construct a scheduler for Matrix. Requires
@@ -60,7 +60,7 @@ function MatrixScheduler(retryAlgorithm, queueAlgorithm) {
* @see MatrixScheduler.removeEventFromQueue To remove an event from the queue.
*/
MatrixScheduler.prototype.getQueueForEvent = function(event) {
var name = this.queueAlgorithm(event);
let name = this.queueAlgorithm(event);
if (!name || !this._queues[name]) {
return null;
}
@@ -76,11 +76,11 @@ MatrixScheduler.prototype.getQueueForEvent = function(event) {
* @return {boolean} True if this event was removed.
*/
MatrixScheduler.prototype.removeEventFromQueue = function(event) {
var name = this.queueAlgorithm(event);
let name = this.queueAlgorithm(event);
if (!name || !this._queues[name]) {
return false;
}
var removed = false;
let removed = false;
utils.removeElement(this._queues[name], function(element) {
if (element.event.getId() === event.getId()) {
removed = true;
@@ -110,7 +110,7 @@ MatrixScheduler.prototype.setProcessFunction = function(fn) {
* resolved or rejected in due time, else null.
*/
MatrixScheduler.prototype.queueEvent = function(event) {
var queueName = this.queueAlgorithm(event);
let queueName = this.queueAlgorithm(event);
if (!queueName) {
return null;
}
@@ -118,11 +118,11 @@ MatrixScheduler.prototype.queueEvent = function(event) {
if (!this._queues[queueName]) {
this._queues[queueName] = [];
}
var defer = q.defer();
let defer = q.defer();
this._queues[queueName].push({
event: event,
defer: defer,
attempts: 0
attempts: 0,
});
debuglog(
"Queue algorithm dumped event %s into queue '%s'",
@@ -155,7 +155,7 @@ MatrixScheduler.RETRY_BACKOFF_RATELIMIT = function(event, attempts, err) {
}
if (err.name === "M_LIMIT_EXCEEDED") {
var waitTime = err.data.retry_after_ms;
let waitTime = err.data.retry_after_ms;
if (waitTime) {
return waitTime;
}
@@ -201,10 +201,10 @@ function _startProcessingQueues(scheduler) {
function _processQueue(scheduler, queueName) {
// get head of queue
var obj = _peekNextEvent(scheduler, queueName);
let obj = _peekNextEvent(scheduler, queueName);
if (!obj) {
// queue is empty. Mark as inactive and stop recursing.
var index = scheduler._activeQueues.indexOf(queueName);
let index = scheduler._activeQueues.indexOf(queueName);
if (index >= 0) {
scheduler._activeQueues.splice(index, 1);
}
@@ -227,7 +227,7 @@ function _processQueue(scheduler, queueName) {
}, function(err) {
obj.attempts += 1;
// ask the retry algorithm when/if we should try again
var waitTimeMs = scheduler.retryAlgorithm(obj.event, obj.attempts, err);
let waitTimeMs = scheduler.retryAlgorithm(obj.event, obj.attempts, err);
debuglog(
"retry(%s) err=%s event_id=%s waitTime=%s",
obj.attempts, err, obj.event.getId(), waitTimeMs
@@ -241,8 +241,7 @@ function _processQueue(scheduler, queueName) {
obj.defer.reject(err);
// process next event
_processQueue(scheduler, queueName);
}
else {
} else {
setTimeout(function() {
_processQueue(scheduler, queueName);
}, waitTimeMs);
@@ -251,7 +250,7 @@ function _processQueue(scheduler, queueName) {
}
function _peekNextEvent(scheduler, queueName) {
var queue = scheduler._queues[queueName];
let queue = scheduler._queues[queueName];
if (!utils.isArray(queue)) {
return null;
}
@@ -259,7 +258,7 @@ function _peekNextEvent(scheduler, queueName) {
}
function _removeNextEvent(scheduler, queueName) {
var queue = scheduler._queues[queueName];
let queue = scheduler._queues[queueName];
if (!utils.isArray(queue)) {
return null;
}
@@ -268,7 +267,7 @@ function _removeNextEvent(scheduler, queueName) {
function debuglog() {
if (DEBUG) {
console.log.apply(console, arguments);
console.log(...arguments);
}
}