Socket
Socket
Sign inDemoInstall

fastq

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastq - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

2

package.json
{
"name": "fastq",
"version": "1.0.2",
"version": "1.1.0",
"description": "Fast, in memory work queue",

@@ -5,0 +5,0 @@ "main": "queue.js",

'use strict'
function fastqueue (worker, limit) {
var cacheHead = new Task(release)
function fastqueue (context, worker, limit) {
if (typeof context === 'function') {
limit = worker
worker = context
context = null
}
var cacheHead = new Task(context, release)
var cacheTail = cacheHead

@@ -30,3 +37,3 @@ var queueHead = null

limit--
worker(current.value, current.worked)
worker.call(context, current.value, current.worked)
}

@@ -41,3 +48,3 @@ }

} else {
cacheHead = new Task(release)
cacheHead = new Task(context, release)
cacheTail = cacheHead

@@ -61,3 +68,3 @@ }

next.next = null
worker(next.value, next.worked)
worker.call(context, next.value, next.worked)
} else {

@@ -71,3 +78,3 @@ limit++

function Task (release) {
function Task (context, release) {
this.value = null

@@ -83,3 +90,3 @@ this.callback = noop

self.callback = noop
callback(err, result)
callback.call(context, err, result)
release(self)

@@ -86,0 +93,0 @@ }

@@ -41,4 +41,24 @@ # fastq  [![build status](https://secure.travis-ci.org/mcollina/fastq.png)](http://travis-ci.org/mcollina/fastq)

### Setting this
```js
'use strict'
var that = { hello: 'world' }
var queue = require('fastq')(that, worker, 1)
queue.push(42, function (err, result) {
if (err) { throw err }
console.log(this)
console.log('the result is', result)
})
function worker (arg, cb) {
console.log(this)
cb(null, 42 * 2)
}
```
## License
ISC

@@ -89,1 +89,18 @@ 'use strict'

})
test('set this', function (t) {
t.plan(3)
var that = {}
var queue = buildQueue(that, worker, 1)
queue.push(42, function (err, result) {
t.error(err, 'no error')
t.equal(this, that, 'this matches')
})
function worker (arg, cb) {
t.equal(this, that, 'this matches')
cb(null, true)
}
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc