├── .nvmrc
├── .npmrc
├── .yarnrc.yml
├── docs
├── public
│ ├── CNAME
│ ├── favicon.png
│ └── logo.svg
├── tsconfig.json
├── .vscode
│ ├── extensions.json
│ └── launch.json
├── src
│ ├── env.d.ts
│ ├── components
│ │ ├── References.astro
│ │ └── Configuration.astro
│ ├── content
│ │ ├── config.ts
│ │ └── docs
│ │ │ ├── reference
│ │ │ ├── properties.mdx
│ │ │ ├── types-and-enums.mdx
│ │ │ ├── methods.mdx
│ │ │ └── configuration.mdx
│ │ │ ├── introduction
│ │ │ ├── index.mdx
│ │ │ ├── getting-started.mdx
│ │ │ └── done-callback.mdx
│ │ │ ├── index.mdx
│ │ │ └── guides
│ │ │ └── migrating-from-v1-v3.mdx
│ └── tailwind.css
├── .gitignore
├── package.json
├── tailwind.config.mjs
├── astro.config.mjs
└── README.md
├── .npmignore
├── icons
├── icon-x64.png
├── icon-x512.png
└── icon.svg
├── src
├── index.ts
├── Namespace.ts
├── DefaultOptions.ts
├── Task.ts
├── Utils.ts
├── __tests__
│ ├── Task.test.ts
│ ├── Utils.test.ts
│ ├── List.test.ts
│ └── TaskRunner.test.ts
├── Interface.ts
├── List.ts
└── TaskRunner.ts
├── .editorconfig
├── tsconfig.build.json
├── .gitignore
├── .prettierrc
├── .size-limit.json
├── bench
├── helpers
│ ├── is-last.ts
│ ├── cpu-usage.ts
│ └── benchmarker.ts
├── units
│ ├── for-each.ts
│ ├── for-loop.ts
│ ├── while-loop.ts
│ └── ct.ts
├── benchmark-setup.ts
├── bench.d.ts
└── benchmarks.ts
├── .vscode
└── settings.json
├── .release-it.json
├── jest.config.ts
├── .github
├── ISSUE_TEMPLATE
│ ├── issue--help-request.md
│ ├── feature_request.md
│ └── bug_report.md
├── setup
│ └── action.yml
└── workflows
│ ├── github-pages.yml
│ └── checks.yml
├── commitlint.config.js
├── lefthook.yml
├── testing-utils
├── setup
│ └── test.setup.ts
└── utils
│ ├── generate-tasks.ts
│ └── create-runner.ts
├── SECURITY.md
├── tsconfig.json
├── .eslintrc
├── LICENSE
├── scripts
└── release.ts
├── rollup.config.js
├── .husky
├── commit-msg
├── pre-commit
└── prepare-commit-msg
├── CONTRIBUTING.md
├── README.md
├── package.json
└── CHANGELOG.md
/.nvmrc:
--------------------------------------------------------------------------------
1 | 18
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | save-exact=false
--------------------------------------------------------------------------------
/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | nodeLinker: node-modules
2 |
--------------------------------------------------------------------------------
/docs/public/CNAME:
--------------------------------------------------------------------------------
1 | concurrent-tasks.samrith.dev
2 |
--------------------------------------------------------------------------------
/docs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "astro/tsconfigs/strict"
3 | }
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | demo/
2 | node_modules/
3 | coverage/
4 | .cache/
5 | *.log
6 | src/__tests__
--------------------------------------------------------------------------------
/icons/icon-x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samrith-s/concurrent-tasks/HEAD/icons/icon-x64.png
--------------------------------------------------------------------------------
/icons/icon-x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samrith-s/concurrent-tasks/HEAD/icons/icon-x512.png
--------------------------------------------------------------------------------
/docs/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samrith-s/concurrent-tasks/HEAD/docs/public/favicon.png
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | export * as CT from "./Namespace";
4 | export { TaskRunner } from "./TaskRunner";
5 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_size = 2
6 | indent_style = space
7 | end_of_line = lf
8 |
--------------------------------------------------------------------------------
/docs/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["astro-build.astro-vscode"],
3 | "unwantedRecommendations": []
4 | }
5 |
--------------------------------------------------------------------------------
/src/Namespace.ts:
--------------------------------------------------------------------------------
1 | export { DefaultOptions } from "./DefaultOptions";
2 | export * from "./Task";
3 | export * from "./Interface";
4 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "ES2015"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/docs/src/env.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/triple-slash-reference */
2 | ///
{required ? 'true' : 'false'}
15 | {type}
20 | {defaultValue}
25 |
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 | A simple task runner which will run all tasks till completion, while maintaining concurrency limits. 24 |
25 | 26 |27 | Read the full documentation at the website 28 |
29 | 30 | --- 31 | 32 | # Introduction 33 | 34 | 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. 35 | 36 | 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. 37 | 38 | - [x] Vanilla JavaScript 39 | - [x] Frontend Frameworks (React, Vue, Angular, etc) 40 | - [x] Backend Frameworks (Express, Hapi, Koa, etc) 41 | - [x] NPM Module 42 | - [x] Node CLI Application 43 | 44 | # Installation 45 | 46 | ### Node 47 | 48 | ```bash 49 | # NPM 50 | npm i concurrent-tasks 51 | 52 | # Yarn 53 | yarn add concurrent-tasks 54 | 55 | # PNPM 56 | pnpm i concurrent-tasks 57 | ``` 58 | 59 | ### Browser 60 | 61 | ```html 62 | 66 | ``` 67 | 68 | ### Bun 69 | 70 | ```bash 71 | bun install concurrent-tasks 72 | ``` 73 | 74 | ### Deno 75 | 76 | ```ts 77 | import { TaskRunner } from "https://cdn.jsdelivr.net/npm/concurrent-tasks/src/index.ts"; 78 | ``` 79 | 80 | # Usage 81 | 82 | > **Important:** Each task passed to the task runner, necessarily has to call the done function. If not, your queue won't process properly. 83 | 84 | ```typescript 85 | import TaskRunner from "concurrent-tasks"; 86 | 87 | const runner = new TaskRunner(); 88 | 89 | function generateTasks() { 90 | const tasks = []; 91 | let count = 1000; 92 | while (count) { 93 | tasks.push((done) => { 94 | setTimeout(() => { 95 | done(); 96 | }, Math.random() * 1000); 97 | }); 98 | count--; 99 | } 100 | return tasks; 101 | } 102 | 103 | runner.addMultiple(generateTasks()); 104 | 105 | runner.start(); 106 | ``` 107 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "concurrent-tasks", 3 | "version": "3.0.2", 4 | "description": "A simple task runner which will run tasks concurrently while maintaining limits.", 5 | "author": "Samrith Shankar", 6 | "license": "MIT", 7 | "homepage": "https://concurrent-tasks.samrith.dev", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/samrith-s/concurrent-tasks.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/samrith-s/concurrent-tasks/issues/new/choose" 14 | }, 15 | "main": "lib/cjs/index.js", 16 | "module": "lib/es/index.js", 17 | "types": "lib/dts/src/index.d.ts", 18 | "source": "src/index.ts", 19 | "react-native": "src/index.ts", 20 | "files": [ 21 | "lib", 22 | "LICENSE", 23 | "README", 24 | "src", 25 | "!src/__tests__" 26 | ], 27 | "publishConfig": { 28 | "access": "public", 29 | "registry": "https://registry.npmjs.org" 30 | }, 31 | "engines": { 32 | "node": ">=18.0.0" 33 | }, 34 | "scripts": { 35 | "bootstrap": "yarn install && yarn --cwd docs install", 36 | "prepublishOnly": "yarn build", 37 | "prebuild": "yarn clean", 38 | "build": "NODE_ENV=production rollup -c rollup.config.js --bundleConfigAsCjs && size-limit", 39 | "clean": "rm -rf lib/", 40 | "test": "jest", 41 | "lint": "eslint src/**/*.ts --cache", 42 | "lint:docs": "eslint docs/**/*.ts --cache", 43 | "prettify": "prettier --write {src,tests,docs}/**/*", 44 | "docs": "yarn --cwd docs", 45 | "release": "vite-node scripts/release", 46 | "bench": "vite-node bench/benchmarks.ts" 47 | }, 48 | "devDependencies": { 49 | "@commitlint/cli": "^18.4.3", 50 | "@commitlint/config-conventional": "^18.4.3", 51 | "@release-it/conventional-changelog": "^8.0.1", 52 | "@rollup/plugin-commonjs": "^25.0.7", 53 | "@rollup/plugin-json": "^6.0.1", 54 | "@rollup/plugin-node-resolve": "^15.2.3", 55 | "@rollup/plugin-strip": "^3.0.4", 56 | "@rollup/plugin-terser": "^0.4.4", 57 | "@size-limit/preset-small-lib": "^11.0.1", 58 | "@types/jest": "^29.5.11", 59 | "@types/node": "^20.10.4", 60 | "@typescript-eslint/eslint-plugin": "^6.13.2", 61 | "@typescript-eslint/parser": "^6.13.2", 62 | "builtin-modules": "^3.3.0", 63 | "eslint": "^8.55.0", 64 | "eslint-config-prettier": "^9.1.0", 65 | "eslint-import-resolver-typescript": "^3.6.1", 66 | "eslint-plugin-import": "^2.29.0", 67 | "eslint-plugin-prettier": "^4.2.1", 68 | "jest": "^29.7.0", 69 | "lefthook": "^1.8.2", 70 | "prettier": "^3.1.0", 71 | "release-it": "^15.7.0", 72 | "rollup": "^4.6.1", 73 | "rollup-plugin-typescript2": "^0.36.0", 74 | "size-limit": "^11.0.1", 75 | "ts-jest": "^29.1.1", 76 | "ts-node": "^10.9.2", 77 | "typescript": "^5.3.3", 78 | "vite-node": "^2.1.4", 79 | "yocto-spinner": "^0.1.1" 80 | }, 81 | "keywords": [ 82 | "concurrent", 83 | "tasks", 84 | "processes", 85 | "threads", 86 | "tasks", 87 | "task", 88 | "worker", 89 | "process", 90 | "run", 91 | "concurrent tasks", 92 | "react concurrent task", 93 | "priority", 94 | "queue", 95 | "priority queue", 96 | "fifo", 97 | "scheduler", 98 | "schedule task" 99 | ], 100 | "packageManager": "yarn@4.9.4" 101 | } 102 | -------------------------------------------------------------------------------- /src/Interface.ts: -------------------------------------------------------------------------------- 1 | import type { Task, Tasks } from "./Task"; 2 | 3 | export type Readonly