1.0.4 • Published 2 years ago

@programic/queue v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@programic/queue

npm version

This is a simple JavaScript/TypeScript queue. It contains a push method to add a task (method) to the queue.

Simple example

import { createQueue } from '@programic/queue';

const queue = createQueue();

queue.push(() => 'First task');
queue.push(async () => 'Second task');

Installation

To use this package, install @programic/queue as a dependency in your project with npm or yarn:

npm install @programic/queue --save
yarn add @programic/queue

Usage

To create a new queue instance, use the createQueue method (like the example above). It has one parameter numberOfParallelTasks which is 1 by default. You can provide a higher value to run multiple tasks simultaneously.

Queue instance properties and methods

Every queue instance has the following methods and properties:

  • enqueuedTasks (property: array) contains the tasks that are waiting to be fired
  • runningTasks (property: Task[]) contains the tasks that are currently running
  • failedTasks (property: FailedTask[]) contains the failed tasks with meta info like the error
  • isRunning (method: boolean) indicates if the queue is running
  • push (method: void) method to push a new task to the queue
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago