A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.
Go to file
2018-08-04 18:03:22 +02:00
test fix(tests): now using tstest 2018-08-04 17:53:22 +02:00
ts fix(tests): now using tstest 2018-08-04 17:53:22 +02:00
.gitignore update dependencies 2016-09-02 18:11:33 +02:00
.gitlab-ci.yml fix(tests): now using tstest 2018-08-04 17:53:22 +02:00
.npmignore update dependencies 2016-09-02 18:11:33 +02:00
LICENSE Initial commit 2016-02-07 22:11:30 +01:00
npmextra.json fix(tests): now using tstest 2018-08-04 17:53:22 +02:00
package-lock.json 2.0.1 2018-08-04 18:02:41 +02:00
package.json fix(package.json): update private param 2018-08-04 18:03:22 +02:00
readme.md fix(docs): update docs 2018-08-04 18:02:41 +02:00
tslint.json update dependencies 2017-02-15 22:52:29 +01:00

taskbuffer

flexible task management. TypeScript ready!

Availabililty

npm git git docs

Status for master

build status coverage report npm downloads per month Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

Install

npm install taskbuffer --save

Concepts

class Task

  • A Task in its most simple form is a function that is executed when the task runs.
  • A Task can have a preTask and an afterTask (those are run before or after the main function whenever the task is called)
  • A Task can be buffered. That means it can be called multiple times in a very short time. However execution happens in line: meaning execution of the task's main function is on halt until the previous task call has finished. You can set bufferMax number, which is the max number of buffered task calls. Any additional calls will then be truncated
  • Task.trigger() and Task.triggerBuffered() always return a Promise which is fullfilled once the related task call has completed.
  • Task.triggered() is an Observable stream that emits events every time a task call is called and every time a call is completed.
  • Task is compatible to gulp streams.

class TaskChain

  • TaskChain extends Task.
  • Multiple Tasks can be combined in a bigger task using a TaskChain.
  • While the tasks are async in themselve, TaskChain runs Tasks serialized (one after the other)
  • that means that tasks can rely on each other and

class TaskParallel

  • TaskParallel extends Task.
  • like TaskChain, however tasks run in parallel
  • Tasks cannot rely on each other.

Usage

We highly recommend TypeScript as this module supports TypeScript intellisense.

import * as taskbuffer from "taskbuffer";

myTask = new taskbuffer.Task({
  preTask: someOtherTask // optional, don't worry loops are prevented
  afterTask: someOtherTask // optional, don't worry loops are prevented
  name:"myTask1",
  buffered: true, // optional
  bufferMax: 3, // optional, call qeues greater than this are truncated
  execDelay: 1000, // optional, time in ms to wait before executing task call
  taskFunction:() => {
    // do some stuff and return promise
    // pass on any data through promise resolution
    // Use TypeScript for better understanding and code completion
  }
})

For further information read the linked docs at the top of this README.

MIT licensed | © Lossless GmbH

repo-footer