Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

fastq 1.17.1

Fast, in memory work queue
Package summary
Share
0
issues
0
licenses
Package created
14 Jun 2015
Version published
5 Feb 2024
Maintainers
1
Total deps
0
Direct deps
0
License
ISC
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does fastq do?

FastQ is a popular npm package that offers a high performance, in-memory work queue. Its main purpose is to manage tasks efficiently in a fast queueing system, which is especially beneficial for Node.js applications where managing asynchronous operations is critical. Elegant in its simplicity, FastQ outperforms several other task queue packages according to benchmarks provided on its official repository.

How do you use fastq?

To use FastQ, start by installing the package using npm with the command npm i fastq --save. After installation, you can import it into your application and create a queue. You should define a worker function and the level of concurrency for the tasks. FastQ provides both a callback API and a promise API. The tasks will be processed by the worker function in accordance with the queue.

A basic usage example is as follows:

'use strict'
const 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, arg * 2)
}

In this example, a worker function is defined which doubles the argument passed to it. The push method is used to add a task (in this case, the number 42) to the queue. The second argument to the push method is a callback function which is executed once the task is processed.

FastQ can also be used with TypeScript and offers methods to pause, resume, check if the queue is idle, get the length of the queue, and much more.

Where are the fastq docs?

The complete FastQ documentation can be found in its official GitHub repository at https://github.com/mcollina/fastq. This documentation provides a comprehensive guide for installation, usage, API details, and several usage examples for various scenarios. FastQ's APIs, such as push, unshift, pause, resume and many more, are particularly detailed in the documentation.