Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samrith-s/concurrent-tasks
A simple task runner which will run all tasks till completion, while maintaining concurrency limits.
https://github.com/samrith-s/concurrent-tasks
concurrent-tasks javascript priority-queue task task-list task-queue task-runner tasks
Last synced: 15 days ago
JSON representation
A simple task runner which will run all tasks till completion, while maintaining concurrency limits.
- Host: GitHub
- URL: https://github.com/samrith-s/concurrent-tasks
- Owner: samrith-s
- License: mit
- Created: 2018-12-01T10:32:17.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-10T14:01:23.000Z (11 months ago)
- Last Synced: 2024-10-13T11:05:47.963Z (30 days ago)
- Topics: concurrent-tasks, javascript, priority-queue, task, task-list, task-queue, task-runner, tasks
- Language: TypeScript
- Homepage: https://concurrent-tasks.js.org
- Size: 1.13 MB
- Stars: 39
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
Concurrent Tasks
A simple task runner which will run all tasks till completion, while maintaining concurrency limits.
Read the full documentation at the website---
# Introduction
Concurrent Tasks mimics a queue by using JavaScript's inbuilt array data type. Each task is a function which signals completion back to the runner.
The minimalism of Concurrent Tasks makes it an easy-to-use solution across any framework or flavour of JavaScript. It has **ZERO dependencies** and can be used virtually in any scenario. With a **minified and gzipped size of 2.7kB**, it is the ultimate lightweight tool for your concurrency needs.
- [x] Vanilla JavaScript
- [x] Frontend Frameworks (React, Vue, Angular, etc)
- [x] Backend Frameworks (Express, Hapi, Koa, etc)
- [x] NPM Module
- [x] Node CLI Application# Installation
### Node
```bash
# NPM
npm i concurrent-tasks# Yarn
yarn add concurrent-tasks# PNPM
pnpm i concurrent-tasks
```### Browser
```html
```
### Bun
```bash
bun install concurrent-tasks
```### Deno
```ts
import { TaskRunner } from "https://cdn.jsdelivr.net/npm/concurrent-tasks/src/index.ts";
```# Usage
> **Important:** Each task passed to the task runner, necessarily has to call the done function. If not, your queue won't process properly.
```typescript
import TaskRunner from "concurrent-tasks";const runner = new TaskRunner();
function generateTasks() {
const tasks = [];
let count = 1000;
while (count) {
tasks.push((done) => {
setTimeout(() => {
done();
}, Math.random() * 1000);
});
count--;
}
return tasks;
}runner.addMultiple(generateTasks());
runner.start();
```