# async-task-mgr

> A simple nodeJS module for async task manager. Identical tasks will be executed only once and the result will be saved for further use.

Latest version **1.1.0** (published 2014-11-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install async-task-mgr
pnpm add async-task-mgr
yarn add async-task-mgr
bun add async-task-mgr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2014-11-28 |
| First published | 2014-08-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Otto Mao |
| Maintainers | ottomao |
| Keywords | async, task, manager |

## Links

- npm: https://www.npmjs.com/package/async-task-mgr
- Repository: https://github.com/ottomao/async-task-mgr
- Issues: https://github.com/ottomao/async-task-mgr/issues
- npm.io page: https://npm.io/package/async-task-mgr

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2014-11-28
- 1.0.2 — 2014-08-14
- 1.0.1 — 2014-08-13
- 1.0.0 — 2014-08-13

## README

async-task-mgr
==============

## Intro
A simple nodeJS module for async task manager. Identical tasks will be executed only once and the result will be saved for further use.

## Features

* tasks with the same name are identified as **the same**, and will be executed only once
* task result will be saved for further use


## How to use

``npm install async-task-mgr --save``

## Sample
```javascript
var asyncTask = require("async-task-mgr");

var asyncTaskInstance = new asyncTask();

function taskAction(callback){
	setTimeout(function(){ //simulate an async task
		var resultA = Math.floor(Math.random()*100),
			resultB = Math.floor(Math.random()*100),
			resultC = Math.floor(Math.random()*100);

		callback(resultA, resultB, resultC);
	},2000); 
}

//add a new task named task_A
//when taskAction is done, its return value will be saved and apply to all the task with the same name
asyncTaskInstance.addTask("task_A",taskAction,function(resultA,resultB,resultC){ 
	console.log("task A_1 result :" + resultA + " " + resultB + " " + resultC); //all result generated by taskAction will be passed here
});


//add a new task named task_A
/*
since a task with the same name has been added, this taskAction will not be executed.
the callback function will be put in a queue and will be called when previous callbacks are done.
*/
asyncTaskInstance.addTask("task_A",taskAction,function(resultA,resultB,resultC){
	console.log("task A_2 result :" + resultA + " " + resultB + " " + resultC);
});


//add a new task named task_X
//a new task, have no relationship to the previous ones
asyncTaskInstance.addTask("task_X",taskAction,function(resultA,resultB,resultC){
	console.log("task X_0 result :" + resultA + " " + resultB + " " + resultC);
});

```

## Author
Otto Mao 
ottomao@gmail.com

---
_Source: https://npm.io/package/async-task-mgr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
