@wireapp/priority-queue
Advanced tools
Comparing version 1.6.17 to 1.6.18
{ | ||
"dependencies": { | ||
"@types/node": "~14", | ||
"logdown": "3.3.1", | ||
"uuidjs": "4.2.6" | ||
"@types/node": "~14" | ||
}, | ||
"devDependencies": { | ||
"@types/karma": "5.0.1", | ||
"cross-env": "7.0.2", | ||
"cross-env": "7.0.3", | ||
"del-cli": "3.0.1", | ||
"jasmine": "3.5.0", | ||
"jasmine": "3.6.3", | ||
"karma": "5.2.3", | ||
@@ -44,4 +42,4 @@ "karma-chrome-launcher": "3.1.0", | ||
}, | ||
"version": "1.6.17", | ||
"gitHead": "d41ad671027086ad79dea3efe4f200ee42d106cf" | ||
"version": "1.6.18", | ||
"gitHead": "baedbbcdfd9da16b1f07fc4dd6af6497f14c2518" | ||
} |
@@ -5,3 +5,2 @@ import { Item } from './Item'; | ||
export declare class PriorityQueue { | ||
private readonly logger; | ||
private readonly config; | ||
@@ -8,0 +7,0 @@ private isRunning; |
@@ -29,8 +29,4 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PriorityQueue = void 0; | ||
const logdown_1 = __importDefault(require("logdown")); | ||
const Item_1 = require("./Item"); | ||
@@ -40,6 +36,2 @@ const Priority_1 = require("./Priority"); | ||
constructor(config) { | ||
this.logger = logdown_1.default('@wireapp/priority-queue/PriorityQueue', { | ||
logger: console, | ||
markdown: false, | ||
}); | ||
this.config = { | ||
@@ -63,16 +55,15 @@ comparator: (a, b) => { | ||
return new Promise((resolve, reject) => { | ||
const queueObject = new Item_1.Item(); | ||
queueObject.fn = thunkedPromise; | ||
queueObject.label = label; | ||
queueObject.priority = priority; | ||
queueObject.reject = reject; | ||
queueObject.resolve = resolve; | ||
queueObject.retry = 0; | ||
queueObject.timestamp = Date.now() + this.size; | ||
this.queue.push(queueObject); | ||
const item = new Item_1.Item(); | ||
item.fn = thunkedPromise; | ||
item.label = label; | ||
item.priority = priority; | ||
item.reject = reject; | ||
item.resolve = resolve; | ||
item.retry = 0; | ||
item.timestamp = Date.now() + this.size; | ||
this.queue.push(item); | ||
this.queue.sort(this.config.comparator); | ||
if (!this.isRunning) { | ||
this.isRunning = true; | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
this.processList(); | ||
void this.processList(); | ||
} | ||
@@ -101,4 +92,4 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queueObject = this.first; | ||
if (!queueObject) { | ||
const item = this.queue.shift(); | ||
if (!item) { | ||
this.isRunning = false; | ||
@@ -108,18 +99,14 @@ return; | ||
try { | ||
queueObject.resolve(yield queueObject.fn()); | ||
this.queue.shift(); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
this.processList(); | ||
item.resolve(yield item.fn()); | ||
void this.processList(); | ||
} | ||
catch (error) { | ||
if (queueObject.retry >= this.config.maxRetries) { | ||
this.queue.shift(); | ||
queueObject.reject(error); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
this.processList(); | ||
if (item.retry >= this.config.maxRetries) { | ||
item.reject(error); | ||
void this.processList(); | ||
} | ||
else { | ||
this.logger.log(`Retrying item "${queueObject}"`); | ||
setTimeout(() => this.processList(), this.getGrowingDelay(queueObject.retry)); | ||
queueObject.retry++; | ||
this.queue.push(item); | ||
setTimeout(() => this.processList(), this.getGrowingDelay(item.retry)); | ||
item.retry++; | ||
} | ||
@@ -126,0 +113,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
118263
299
- Removedlogdown@3.3.1
- Removeduuidjs@4.2.6
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedlogdown@3.3.1(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removeduuidjs@4.2.6(transitive)