Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "fastq", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Fast, in memory work queue", | ||
@@ -33,6 +33,9 @@ "main": "queue.js", | ||
"pre-commit": "^1.0.10", | ||
"standard": "^4.2.1", | ||
"standard": "^5.2.0", | ||
"tap-spec": "^4.0.0", | ||
"tape": "^4.0.0" | ||
}, | ||
"dependencies": { | ||
"reusify": "^1.0.0" | ||
} | ||
} |
35
queue.js
'use strict' | ||
var reusify = require('reusify') | ||
function fastqueue (context, worker, limit) { | ||
@@ -10,4 +12,3 @@ if (typeof context === 'function') { | ||
var cacheHead = new Task(context, release) | ||
var cacheTail = cacheHead | ||
var cache = reusify(Task) | ||
var queueHead = null | ||
@@ -22,4 +23,6 @@ var queueTail = null | ||
function push (value, done) { | ||
var current = next() | ||
var current = cache.get() | ||
current.context = context | ||
current.release = release | ||
current.value = value | ||
@@ -42,20 +45,4 @@ current.callback = done | ||
function next () { | ||
var task = cacheHead | ||
if (task.next) { | ||
cacheHead = task.next | ||
} else { | ||
cacheHead = new Task(context, release) | ||
cacheTail = cacheHead | ||
} | ||
task.next = null | ||
return task | ||
} | ||
function release (holder) { | ||
cacheTail.next = holder | ||
cacheTail = holder | ||
cache.release(holder) | ||
var next = queueHead | ||
@@ -77,6 +64,8 @@ if (next) { | ||
function Task (context, release) { | ||
function Task () { | ||
this.value = null | ||
this.callback = noop | ||
this.next = null | ||
this.release = noop | ||
this.context = null | ||
@@ -89,4 +78,4 @@ var self = this | ||
self.callback = noop | ||
callback.call(context, err, result) | ||
release(self) | ||
callback.call(self.context, err, result) | ||
self.release(self) | ||
} | ||
@@ -93,0 +82,0 @@ } |
@@ -0,0 +0,0 @@ # fastq [![build status](https://secure.travis-ci.org/mcollina/fastq.png)](http://travis-ci.org/mcollina/fastq) |
@@ -0,0 +0,0 @@ 'use strict' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
7989
1
197
+ Addedreusify@^1.0.0
+ Addedreusify@1.0.4(transitive)