{"id":23454939,"url":"https://github.com/lilbunnyrabbit/task-manager","last_synced_at":"2025-04-14T00:15:44.498Z","repository":{"id":257802528,"uuid":"769377637","full_name":"lilBunnyRabbit/task-manager","owner":"lilBunnyRabbit","description":"System for managing and executing asynchronous and synchronous tasks with queuing, parallel execution, and progress tracking.","archived":false,"fork":false,"pushed_at":"2025-02-18T22:27:37.000Z","size":847,"stargazers_count":4,"open_issues_count":18,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T00:15:32.817Z","etag":null,"topics":["async-tasks","npm-package","parallel-execution","task-manager","task-queue","typescript-library","typescrpt"],"latest_commit_sha":null,"homepage":"https://lilbunnyrabbit.github.io/task-manager","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lilBunnyRabbit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-08T23:24:53.000Z","updated_at":"2025-02-18T22:27:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"65797022-e4b0-4e07-b30f-d2c4419d3c38","html_url":"https://github.com/lilBunnyRabbit/task-manager","commit_stats":null,"previous_names":["lilbunnyrabbit/task-manager"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Ftask-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Ftask-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Ftask-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Ftask-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lilBunnyRabbit","download_url":"https://codeload.github.com/lilBunnyRabbit/task-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799953,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-tasks","npm-package","parallel-execution","task-manager","task-queue","typescript-library","typescrpt"],"created_at":"2024-12-24T03:17:55.025Z","updated_at":"2025-04-14T00:15:44.487Z","avatar_url":"https://github.com/lilBunnyRabbit.png","language":"HTML","readme":"# [TypeScript Task Manager](https://lilbunnyrabbit.github.io/task-manager)\n\n[![npm version](https://img.shields.io/npm/v/@lilbunnyrabbit/task-manager.svg)](https://www.npmjs.com/package/@lilbunnyrabbit/task-manager)\n[![npm downloads](https://img.shields.io/npm/dt/@lilbunnyrabbit/task-manager.svg)](https://www.npmjs.com/package/@lilbunnyrabbit/task-manager)\n\nA flexible and powerful task management system built with [TypeScript](https://www.typescriptlang.org/). It helps in managing both **synchronous** and **asynchronous** tasks with ease, allowing you to queue tasks, execute them **sequentially** or **in parallel**, and monitor their progress.\n\n\u003e **✨ Check out the [Landing Page](https://lilbunnyrabbit.github.io/task-manager) for an Overview, Examples, and Use Cases!**\n\n## 🚀 Installation\n\nTo install the package, run:\n\n```sh\nnpm i @lilbunnyrabbit/task-manager\n```\n\n## 🎯 Features\n\n- **Task Orchestration** – Manage workflows with **sequential** or **parallel** execution.\n- **Progress Tracking** – Monitor task progress with built-in state handling.\n- **Type Safety** – Built with TypeScript for safe task handling.\n- **Composable Workflows** – Reuse task groups for structured execution.\n- **Error Recovery** – Handle failures and continue execution.\n- **Query Interface** – Access task results, states, and logs.\n\nFor more details, visit the **[API Documentation](https://lilbunnyrabbit.github.io/task-manager/docs/api/v1.0.0/index.html)**.\n\n## 🔥 Getting Started\n\nThis system revolves around three core components: **[`Task`](#task)**, **[`TaskGroup`](#taskgroup)**, and **[`TaskManager`](#taskmanager)**.\n\n- **[`Task`](#task)**: Represents a single unit of work with its own logic, data, execution state, and error handling.\n- **[`TaskGroup`](#taskgroup)**: Allows grouping related tasks together, managing dependencies, and structuring workflows.\n- **[`TaskManager`](#taskmanager)**: Orchestrates execution, handles progress tracking, and manages error recovery.\n\n\n### Creating a Task\nDefine a task using `createTask`:\n\n```ts\nimport { createTask } from \"@lilbunnyrabbit/task-manager\";\n\nconst myTask = createTask\u003cnumber, string\u003e({\n  name: \"Example Task\",\n  async execute(id) {\n    return `Task #${id} Completed!`;\n  },\n});\n```\n\n### Grouping Tasks with TaskGroup\nA `TaskGroup` allows structuring workflows by managing multiple tasks:\n\n```ts\nimport { createTaskGroup } from \"@lilbunnyrabbit/task-manager\";\n\nconst exampleGroup = createTaskGroup({\n  name: \"Example Group\",\n  tasks(ids: number[]) {\n    return ids.map((id) =\u003e myTask(id));\n  },\n});\n```\n\n### Managing Execution with TaskManager\nA `TaskManager` runs and tracks task execution:\n\n```ts\nimport { TaskManager } from \"@lilbunnyrabbit/task-manager\";\n\nconst manager = new TaskManager();\nmanager.addTasks(exampleGroup([1, 2, 3]), myTask(4));\nmanager.start();\n```\n\nFor **more examples**, visit the [Examples Section](https://lilbunnyrabbit.github.io/task-manager/#/examples).\n\n## 📂 Use Cases\n\nSome practical use cases of `@lilbunnyrabbit/task-manager` include:\n\n- **[File Upload Workflow](https://lilbunnyrabbit.github.io/task-manager/#/examples?example=real-life-file-upload)** – Upload files in chunks and track progress.\n- **[CI/CD Pipelines](https://lilbunnyrabbit.github.io/task-manager/#/examples?example=real-life-ci-cd-pipeline)** – Automate build, test, and deploy tasks.\n- **[Image Processing](https://lilbunnyrabbit.github.io/task-manager/#/examples?example=real-life-image-processing)** – Process images with transformations.\n- **[API Request Handling](https://lilbunnyrabbit.github.io/task-manager/#/examples?example=real-life-api-request)** – Fetch and process multiple API responses.\n\nSee more in the [Use Cases Section](https://lilbunnyrabbit.github.io/task-manager/#/?section=section-use-cases).\n\n\n## 📚 API Overview\n\nThis section provides a rough TypeScript definition of the main components.\n\n### Task\nA `Task` represents a unit of work with execution logic, progress tracking, and result management.\n\n```ts\ninterface Task\u003cTSpec extends TaskSpec\u003e extends TaskBase\u003cTSpec\u003e {\n  readonly id: string;\n  readonly name: string;\n  readonly data: TSpec[\"TData\"]\n  readonly builder: TaskBuilder\u003cTSpec\u003e\n  readonly logs: LogEntry[];\n  readonly query?: TaskQuery;\n\n  execute(): Promise\u003cOptional\u003cTSpec[\"TResult\"]\u003e\u003e;\n  parse(): ParsedTask;\n  toString(pretty?: boolean): string;\n  clone(): Task\u003cTSpec\u003e;\n}\n```\n\n### TaskGroup\nA `TaskGroup` manages multiple tasks and defines execution order.\n\n```ts\ninterface TaskGroup\u003cTArgs extends unknown[]\u003e extends TaskGroupBase {\n  readonly id: string;\n  readonly name: string;\n  readonly args: TArgs;\n  readonly builder: TaskGroupBuilder\u003cTArgs\u003e;\n  readonly mode: ExecutionMode;\n  readonly tasks: ExecutableTask[];\n  readonly query: TaskQuery;\n\n  execute(): Promise\u003cthis\u003e;\n  toString(pretty?: boolean): string;\n  clone(): TaskGroup\u003cTArgs\u003e;\n}\n```\n\n### TaskManager\nA `TaskManager` executes tasks, tracks progress, and manages execution settings.\n\n```ts\ninterface TaskManager extends TaskManagerBase {\n  readonly tasks: ExecutableTask[];\n  readonly query: TaskQuery;\n\n  addTask(task: ExecutableTask): this;\n  addTasks(...tasks: ExecutableTask[]): this;\n  start(force?: boolean): Promise\u003cvoid\u003e;\n  stop(): void;\n  reset(): void;\n  clearQueue(): this;\n}\n```\n\nFor **full API documentation**, visit the [Docs](https://lilbunnyrabbit.github.io/task-manager/docs/api/v1.0.0/index.html).\n\n\n## 🔧 Development\n\n### Setup\nClone the repository and install dependencies:\n\n```sh\ngit clone https://github.com/lilBunnyRabbit/task-manager.git\ncd task-manager\nnpm install\n```\n\n### Available Scripts\n| Command                 | Description                                                                                           |\n| ----------------------- | ----------------------------------------------------------------------------------------------------- |\n| `npm run build`         | Compiles [TypeScript](https://www.typescriptlang.org/) code.                                          |\n| `npm test`              | Runs tests with [Jest](https://jestjs.io/).                                                           |\n| `npm run clean`         | Clears `dist/` and `node_modules/`.                                                                   |\n| `npm run changeset`     | Manages versioning and changelog updates with [Changesets](https://github.com/changesets/changesets). |\n| `npm run release`       | Publishes the package to npm.                                                                         |\n| `npm run generate:docs` | Generates API documentation.                                                                          |\n\n\n## 📦 Related Packages\n\nThese utilities complement `@lilbunnyrabbit/task-manager`:\n\n| Package                                                                                          | Description                                        |\n| ------------------------------------------------------------------------------------------------ | -------------------------------------------------- |\n| **[@lilbunnyrabbit/event-emitter](https://www.npmjs.com/package/@lilbunnyrabbit/event-emitter)** | A lightweight event system for tasks.              |\n| **[@lilbunnyrabbit/optional](https://www.npmjs.com/package/@lilbunnyrabbit/optional)**           | A TypeScript utility for handling optional values. |\n| **[@lilbunnyrabbit/utils](https://www.npmjs.com/package/@lilbunnyrabbit/utils)**                 | Collection of helper functions and utilities.      |\n\n\n## 🎉 Contribution\n\nContributions are always welcome! For any enhancements or bug fixes, please open a pull request linked to the relevant issue. If there's no existing issue related to your contribution, feel free to create one.\n\n## 💖 Support\n\nYour support is greatly appreciated! If this package has been helpful, consider supporting its development. Your contributions help maintain and improve this project.  \n\n[![GitHub Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/lilBunnyRabbit)\n\n## 📜 License\n\nMIT © Andraž Mesarič-Sirec","funding_links":["https://github.com/sponsors/lilBunnyRabbit"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilbunnyrabbit%2Ftask-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flilbunnyrabbit%2Ftask-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilbunnyrabbit%2Ftask-manager/lists"}