1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

First pass at linting lib dir

This commit is contained in:
Laurent Cozic
2019-07-29 15:43:53 +02:00
parent 64b7bc3d62
commit 86dc72b204
170 changed files with 4140 additions and 3119 deletions

View File

@@ -4,7 +4,6 @@ const Setting = require('lib/models/Setting');
const { Logger } = require('lib/logger.js');
class TaskQueue {
constructor(name) {
this.waitingTasks_ = [];
this.processingTasks_ = {};
@@ -47,7 +46,7 @@ class TaskQueue {
this.results_[task.id] = r;
this.processQueue_();
}
};
while (this.waitingTasks_.length > 0 && Object.keys(this.processingTasks_).length < this.concurrency()) {
if (this.stopping_) break;
@@ -55,19 +54,22 @@ class TaskQueue {
const task = this.waitingTasks_.splice(0, 1)[0];
this.processingTasks_[task.id] = task;
task.callback().then(result => {
completeTask(task, result, null);
}).catch(error => {
if (!error) error = new Error('Unknown error');
completeTask(task, null, error);
});
task
.callback()
.then(result => {
completeTask(task, result, null);
})
.catch(error => {
if (!error) error = new Error('Unknown error');
completeTask(task, null, error);
});
}
this.processingQueue_ = false;
}
isWaiting(taskId) {
return this.waitingTasks_.find(task => task.id === taskId)
return this.waitingTasks_.find(task => task.id === taskId);
}
isProcessing(taskId) {
@@ -118,9 +120,8 @@ class TaskQueue {
isStopping() {
return this.stopping_;
}
}
TaskQueue.CONCURRENCY = 5;
module.exports = TaskQueue;
module.exports = TaskQueue;