{"id":23377983,"url":"https://github.com/beyondjs/execution-control","last_synced_at":"2025-10-26T10:33:22.045Z","repository":{"id":253717074,"uuid":"844288171","full_name":"beyondjs/execution-control","owner":"beyondjs","description":"A lightweight library for managing single-function execution and cancellation tokens in TypeScript. Prevents redundant function calls and provides control over async operation cancellation.","archived":false,"fork":false,"pushed_at":"2024-08-18T23:51:04.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-14T03:34:41.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beyondjs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-08-18T23:51:02.000Z","updated_at":"2024-08-19T00:32:06.000Z","dependencies_parsed_at":"2024-08-19T02:43:46.894Z","dependency_job_id":"6bb4c331-5625-4fac-b403-ded422e0dd71","html_url":"https://github.com/beyondjs/execution-control","commit_stats":null,"previous_names":["beyondjs/execution-control"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fexecution-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fexecution-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fexecution-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fexecution-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyondjs","download_url":"https://codeload.github.com/beyondjs/execution-control/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247779763,"owners_count":20994572,"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":[],"created_at":"2024-12-21T18:33:41.952Z","updated_at":"2025-10-26T10:33:17.007Z","avatar_url":"https://github.com/beyondjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Execution Control\n\nThis package contains two independent modules designed to enhance control over function execution in\nJavaScript/TypeScript projects. It includes a decorator for managing single execution of functions and a class for\nhandling cancellation tokens.\n\n## Installation\n\nInstall via npm:\n\n```bash\nnpm install execution-control\n```\n\n## Modules\n\n### 1. SingleCall Decorator\n\nThis decorator ensures that a function can only be called once at a time for a given instance. If the function is\nalready in progress, the same promise is returned instead of invoking the function again.\n\n#### Usage\n\n```typescript\nimport { SingleCall } from 'execution-control/single-call';\n\nclass Example {\n\t@SingleCall\n\tasync fetchData() {\n\t\t// Your logic here\n\t}\n}\n```\n\nIn this example, multiple calls to `fetchData()` while a promise is pending will all return the same promise.\n\n### 2. CancellationToken Class\n\nThe `CancellationToken` class provides a mechanism to manage and verify cancellation tokens in asynchronous processes.\n\n#### Usage\n\n```typescript\nimport { CancellationToken } from 'execution-control/cancelation-token';\n\nconst token = new CancellationToken();\n\nasync function fetchData() {\n\tconst id = token.reset();\n\n\t// Perform some operation\n\tif (!token.check(id)) {\n\t\t// Handle cancellation\n\t}\n}\n```\n\nThe `reset()` method generates a new token, while `check(id)` verifies if the current operation is still valid based on\nthe last token.\n\n## Module Overview\n\n-   **SingleCall**: Prevents simultaneous calls to the same function, returning the first in-progress promise for\n    subsequent calls.\n-   **CancellationToken**: Provides a way to control and cancel long-running or asynchronous operations.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fexecution-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyondjs%2Fexecution-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fexecution-control/lists"}