{"id":26664371,"url":"https://github.com/leawind/tuzk-ts","last_synced_at":"2026-05-18T10:09:08.383Z","repository":{"id":284300294,"uuid":"954427543","full_name":"Leawind/tuzk-ts","owner":"Leawind","description":"A TypeScript library for managing asynchronous tasks with support for dependencies and progress tracking.","archived":false,"fork":false,"pushed_at":"2025-05-01T12:50:26.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-20T00:03:12.239Z","etag":null,"topics":["async","deno","jsr","lib","task","typescript"],"latest_commit_sha":null,"homepage":"https://jsr.io/@leawind/tuzk","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Leawind.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-03-25T04:15:54.000Z","updated_at":"2025-05-01T12:47:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"f392d574-5e9d-4703-a33a-e7610a7a9dd5","html_url":"https://github.com/Leawind/tuzk-ts","commit_stats":null,"previous_names":["leawind/tuzk-ts"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Leawind/tuzk-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Ftuzk-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Ftuzk-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Ftuzk-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Ftuzk-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leawind","download_url":"https://codeload.github.com/Leawind/tuzk-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Ftuzk-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260852084,"owners_count":23072586,"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","deno","jsr","lib","task","typescript"],"created_at":"2025-03-25T16:28:01.611Z","updated_at":"2026-05-18T10:09:08.377Z","avatar_url":"https://github.com/Leawind.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tuzk\n\n[![GitHub License](https://img.shields.io/github/license/Leawind/tuzk-ts)](https://github.com/Leawind/tuzk-ts)\n[![JSR Version](https://jsr.io/badges/@leawind/tuzk)](https://jsr.io/@leawind/tuzk)\n[![deno score](https://jsr.io/badges/@leawind/tuzk/score)](https://jsr.io/@leawind/tuzk/doc)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Leawind/tuzk-ts/deno-test.yaml?branch=main\u0026logo=github-actions\u0026label=test)](https://github.com/Leawind/tuzk-ts/actions/workflows/deno-test.yaml)\n\nTuzk is a library for managing asynchronous tasks with progress tracking and error handling.\n\n## Features\n\n- **Task Management**: Run, pause, resume, and cancel tasks with intuitive APIs.\n- **Progress Tracking**: Track task progress with checkpoint markers and percentage-based updates.\n- **Error Handling**: Handle task errors with custom error types and centralized error reporting.\n- **Concurrency Support**: Combine multiple tasks using `Tuzk.all()` and `Tuzk.parallel()`. Or Control concurrency with `TuzkManager`.\n\n## Installation\n\n```bash\nnpm install @leawind/tuzk\n```\n\n## Usage\n\n### Basic Task\n\nCreate and run a simple task:\n\n```typescript\nimport { Tuzk } from '@leawind/tuzk';\n\nconst task = new Tuzk\u003cnumber\u003e(async (tuzk) =\u003e {\n\tlet sum = 0;\n\tfor (let i = 1; i \u003c= 100; i++) {\n\t\tsum += i;\n\t\tawait tuzk.checkpoint(i / 100); // Update progress\n\t}\n\treturn sum;\n});\n\nassert(task.stateIs('pending'));\nconst result = await task.run();\nassert(task.stateIs('success'));\n\nassert(result === 5050);\n```\n\n### Task Management with TuzkManager\n\nManage multiple tasks with controlled concurrency:\n\n```typescript\nimport { Tuzk, TuzkManager } from '@leawind/tuzk';\n\nconst manager = new TuzkManager(3); // Max 3 concurrent tasks\n\nfor (let i = 0; i \u003c 10; i++) {\n\tmanager.submit(async () =\u003e {\n\t\tawait new Promise((r) =\u003e setTimeout(r, 100));\n\t\treturn i;\n\t});\n}\n\nawait manager.waitForAll();\n```\n\n### Task Control\n\n#### Pause/Resume\n\n```typescript\nimport { Tuzk } from '@leawind/tuzk';\n\nconst task = new Tuzk(async (tuzk) =\u003e {\n\tfor (let i = 0; i \u003c 100; i++) {\n\t\tawait tuzk.checkpoint(i / 100);\n\t}\n});\n\n// Start the task\nconst promise = task.run();\n\n// Pause after some time\nsetTimeout(() =\u003e {\n\ttask.pause();\n}, 500);\n\n// Resume after some time\nsetTimeout(() =\u003e {\n\ttask.resume();\n}, 1000);\n\n// Wait for completion\nawait promise;\n```\n\n#### Cancel\n\n```typescript\nimport { Tuzk } from '@leawind/tuzk';\n\nconst task = new Tuzk(async (tuzk) =\u003e {\n\tawait tuzk.checkpoint(0.5);\n});\n\n// Start the task\nconst promise = task.run();\n\n// Cancel after some time\nsetTimeout(() =\u003e {\n\ttask.cancel();\n}, 300);\n\ntry {\n\tawait promise;\n} catch (error) {\n\tconsole.log('Task was cancelled');\n}\n```\n\n#### Combine\n\n```typescript\nimport { Tuzk } from '@leawind/tuzk';\n\nconst tasks = [\n\tnew Tuzk(async (tuzk) =\u003e {\n\t\tawait tuzk.checkpoint(0.5);\n\t\treturn 1;\n\t}),\n\tnew Tuzk(async (tuzk) =\u003e {\n\t\tawait tuzk.checkpoint(0.5);\n\t\treturn 2;\n\t}),\n];\n\nconst allTasks = Tuzk.all(tasks);\nconst results = await allTasks.run();\n\nconsole.log(results); // [1, 2]\n```\n\n#### Race\n\n```typescript\nimport { Tuzk } from '@leawind/tuzk';\n\nconst tasks = [\n\tnew Tuzk(async () =\u003e 'slow'),\n\tnew Tuzk(async () =\u003e 'fast'),\n];\n\nconst raceTask = Tuzk.race(tasks);\nconst result = await raceTask.run();\n\nconsole.log(result); // 'fast'\n```\n\n## Task State Diagram\n\n```mermaid\nflowchart TB\n\tPending ==\u003e Running\n\n\tRunning \u003c==\u003e Paused\n\n\tRunning ==\u003e Succeed\n\tRunning --\u003e Failed\n\n\tRunning --\u003e Cancelled\n\tPaused --\u003e Cancelled\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleawind%2Ftuzk-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleawind%2Ftuzk-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleawind%2Ftuzk-ts/lists"}