promise-blocking-queue
Advanced tools
+4
-0
@@ -8,4 +8,8 @@ # Changelog | ||
| ## v0.0.2 | ||
| Use new version of linked-list | ||
| ## v0.0.1 | ||
| First version! |
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const events_1 = require("events"); | ||
| const LinkedList = require("linked-list"); | ||
| const linked_list_1 = require("linked-list"); | ||
| class Node extends linked_list_1.Item { | ||
| constructor(item) { | ||
| super(); | ||
| this.item = item; | ||
| } | ||
| } | ||
| class BlockingQueue extends events_1.EventEmitter { | ||
| constructor(options) { | ||
| super(); | ||
| this._queue = []; | ||
| this._queue = new LinkedList(); | ||
| this._activeCount = 0; | ||
@@ -29,3 +37,3 @@ options = options || {}; | ||
| else { | ||
| this._queue.push(item); | ||
| this._queue.append(new Node(item)); | ||
| } | ||
@@ -41,9 +49,10 @@ return { | ||
| get pendingCount() { | ||
| return this._queue.length; | ||
| return this._queue.size; | ||
| } | ||
| _next() { | ||
| this._activeCount--; | ||
| const item = this._queue.shift(); | ||
| if (item) { | ||
| this._run(item); | ||
| const node = this._queue.head; | ||
| if (node) { | ||
| node.detach(); | ||
| this._run(node.item); | ||
| } | ||
@@ -50,0 +59,0 @@ else { |
+4
-1
| { | ||
| "name": "promise-blocking-queue", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "Memory optimized promise blocking queue with concurrency control", | ||
@@ -74,3 +74,6 @@ "main": "dist/index.js", | ||
| "typescript": "^3.5.3" | ||
| }, | ||
| "dependencies": { | ||
| "linked-list": "^2.1.0" | ||
| } | ||
| } |
33577
1.06%159
6%1
Infinity%+ Added
+ Added