Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.7.0 to 1.8.0

17

index.d.ts

@@ -1,11 +0,11 @@

declare function fastq<T>(context: T, worker: fastq.worker<T>, concurrency: number): fastq.queue
declare function fastq<T>(worker: fastq.worker<T>, concurrency: number): fastq.queue
declare function fastq<C, T = any, R = any>(context: C, worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
declare function fastq<C, T = any, R = any>(worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
declare namespace fastq {
type worker<T> = (this: T, arg: any, cb: () => void) => void
type done = (err: Error, result: any) => void
type worker<C, T = any, R = any> = (this: C, task: T, cb: fastq.done<R>) => void
type done<R = any> = (err: Error | null, result?: R) => void
interface queue {
push(task: any, done: done): void
unshift(task: any, done: done): void
interface queue<T = any, R = any> {
push(task: T, done: done<R>): void
unshift(task: T, done: done<R>): void
pause(): any

@@ -15,2 +15,3 @@ resume(): any

length(): number
getQueue(): T[]
kill(): any

@@ -25,2 +26,2 @@ killAndDrain(): any

export = fastq
export = fastq
{
"name": "fastq",
"version": "1.7.0",
"version": "1.8.0",
"description": "Fast, in memory work queue",

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

import * as fastq from '../'
const queue = fastq({ hello: 'world' }, worker, 1)
// Basic example
queue.push(42, (err, done) => {
const queue = fastq(worker, 1)
queue.push('world', (err, result) => {
if (err) throw err
console.log('the result is', done)
console.log('the result is', result)
})

@@ -16,2 +18,4 @@

console.log('the queue tasks are', queue.getQueue())
queue.idle()

@@ -31,9 +35,31 @@

queue.unshift(42, (err, done) => {
queue.unshift('world', (err, result) => {
if (err) throw err
console.log('the result is', result)
})
function worker(task: any, cb: fastq.done) {
cb(null, 'hello ' + task)
}
// Generics example
interface GenericsContext {
base: number;
}
const genericsQueue = fastq<GenericsContext, number, string>({ base: 6 }, genericsWorker, 1)
genericsQueue.push(7, (err, done) => {
if (err) throw err
console.log('the result is', done)
})
function worker(arg: any, cb: any) {
cb(null, 42 * 2)
genericsQueue.unshift(7, (err, done) => {
if (err) throw err
console.log('the result is', done)
})
function genericsWorker(this: GenericsContext, task: number, cb: fastq.done<string>) {
cb(null, 'the meaning of life is ' + (this.base * task))
}
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