Skip to content

Simple queuing functionality with event emitter async call for Javascript and Typescript

Notifications You must be signed in to change notification settings

puncoz-official/queueable-js

Repository files navigation

queueable-js

Version Build Twitter Follow

Simple queuing functionality with event emitter async call.

Forked and Inspired from async-function-queue

Installation

$ yarn add queueable-js

or,
$ npm install queueable-js

Usage

import Queue from "queueable-js"

const concurrency = 2

// create a queue, defining concurrency
const queue = Queue(concurrency)

// push a function that accepts a callback
// as sole argument
queue.push(function(cb) {
  setTimeout(cb, 1000)
});

Events

// Some emitted events

// queue.event() will returns an instance of EventEmitter
 
queue.event().on('entry', function() {
  console.log('starting to execute function')
})
 
queue.event().on('exit', function() {
  console.log('finished executing function')
})

queue.event().on('drain', function() {
  console.log('queue has drained')
})

About

Simple queuing functionality with event emitter async call for Javascript and Typescript

Resources

Stars

Watchers

Forks

Packages

No packages published