This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/fastq
cranberry ed23347e56 Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
..
.github/workflows Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
test Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
LICENSE Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
README.md Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
bench.js Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
example.js Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
index.d.ts Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
package.json Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
queue.js Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00

README.md

fastq

ci npm version Dependency Status

Fast, in memory work queue. fastq is API compatible with async.queue

Benchmarks (1 million tasks):

  • setImmediate: 812ms
  • fastq: 854ms
  • async.queue: 1298ms
  • neoAsync.queue: 1249ms

Obtained on node 12.16.1, on a dedicated server.

If you need zero-overhead series function call, check out fastseries. For zero-overhead parallel function call, check out fastparallel.

js-standard-style

Install

npm i fastq --save

Usage

'use strict'

var queue = require('fastq')(worker, 1)

queue.push(42, function (err, result) {
  if (err) { throw err }
  console.log('the result is', result)
})

function worker (arg, cb) {
  cb(null, 42 * 2)
}

Setting this

'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)
}

API

### fastqueue([that], worker, concurrency)
### queue.push(task, done)
Add a task at the end of the queue. done(err, result) will be called when the task was processed.

### queue.unshift(task, done)

Add a task at the beginning of the queue. done(err, result) will be called when the task was processed.

### queue.pause()
### queue.resume()
Resume the processing of tasks.

### queue.idle()

Returns false if there are tasks being processed or waiting to be processed. true otherwise.

### queue.length()
### queue.getQueue()
Returns all the tasks be processed (in the queue). Returns empty array when there are no tasks

### queue.kill()

Removes all tasks waiting to be processed, and reset drain to an empty function.

### queue.killAndDrain()
### queue.concurrency
Property that returns the number of concurrent tasks that could be executed in parallel. It can be altered at runtime.

### queue.drain

Function that will be called when the last item from the queue has been processed by a worker. It can be altered at runtime.

### queue.empty
Function that will be called when the last item from the queue has been assigned to a worker. It can be altered at runtime.

### queue.saturated

Function that will be called when the queue hits the concurrency limit. It can be altered at runtime.

License

ISC