{"id":26664409,"url":"https://github.com/leawind/delegate-ts","last_synced_at":"2026-04-28T20:36:08.044Z","repository":{"id":283920307,"uuid":"953294226","full_name":"Leawind/delegate-ts","owner":"Leawind","description":"A TypeScript library for managing a list of listeners and broadcasting events to them with priority support.","archived":false,"fork":false,"pushed_at":"2025-03-24T15:54:56.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T16:39:31.879Z","etag":null,"topics":["deno","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://jsr.io/@leawind/delegate","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}},"created_at":"2025-03-23T02:32:38.000Z","updated_at":"2025-03-24T15:54:59.000Z","dependencies_parsed_at":"2025-03-24T16:49:37.881Z","dependency_job_id":null,"html_url":"https://github.com/Leawind/delegate-ts","commit_stats":null,"previous_names":["leawind/delegate-deno","leawind/delegate-ts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Fdelegate-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Fdelegate-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Fdelegate-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leawind%2Fdelegate-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leawind","download_url":"https://codeload.github.com/Leawind/delegate-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245499436,"owners_count":20625369,"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":["deno","typescript","typescript-library"],"created_at":"2025-03-25T16:28:11.353Z","updated_at":"2026-04-28T20:36:08.039Z","avatar_url":"https://github.com/Leawind.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@leawind/delegate`\n\n[![GitHub License](https://img.shields.io/github/license/Leawind/delegate-ts)](https://github.com/Leawind/delegate-ts)\n[![JSR Version](https://jsr.io/badges/@leawind/delegate)](https://jsr.io/@leawind/delegate)\n[![deno score](https://jsr.io/badges/@leawind/delegate/score)](https://jsr.io/@leawind/delegate/doc)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Leawind/delegate-ts/deno-test.yaml?branch=main\u0026logo=github-actions\u0026label=test)](https://github.com/Leawind/delegate-ts/actions/workflows/deno-test.yaml)\n\n`Delegate` handles event listeners with features such as priority-based execution, one-time listeners, listener keys, and event control mechanisms. Ideal for scenarios requiring fine-grained control over event propagation and handler lifecycle management.\n\n## Features\n\n- **Priority Control** Define execution order using priorities. Higher-priority listeners run first.\n- **Listener Keys** Associate listeners with unique keys to override or manage them independently.\n- **Event Object API**\n  - `event.data` Get the event data which being broadcasted.\n  - `event.stop()`: Stop the event from propagating to other listeners.\n  - `event.removeSelf()`: Remove the current listener from the delegate.\n\n## Installation\n\n|          |                                      |\n| -------- | ------------------------------------ |\n| **deno** | `deno add jsr:@leawind/delegate`     |\n| **npm**  | `npx jsr add @leawind/delegate`      |\n| **yarn** | `yarn dlx jsr add @leawind/delegate` |\n| **pnpm** | `pnpm dlx jsr add @leawind/delegate` |\n| **bun**  | `bunx jsr add @leawind/delegate`     |\n\n## Example\n\nHere is a simple example of how to use `Delegate` in TypeScript:\n\n```typescript\nimport { Delegate } from '@leawind/delegate';\n\n// Create a new delegate\n// The type of the event data is `string`\nconst delegate = new Delegate\u003cstring\u003e('Example');\n\nlet str = '';\n\ndelegate.addListener((event) =\u003e {\n\tstr += event.data;\n});\n\ndelegate.broadcast('Hello');\ndelegate.broadcast(', World!');\n\nassertStrictEquals(str, 'Hello, World!');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleawind%2Fdelegate-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleawind%2Fdelegate-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleawind%2Fdelegate-ts/lists"}