{"id":25070778,"url":"https://github.com/yamiteru/ueve","last_synced_at":"2025-10-21T21:31:11.504Z","repository":{"id":63379246,"uuid":"567406751","full_name":"yamiteru/ueve","owner":"yamiteru","description":"🔥 Hellishly fast and 🤏 tiny async/sync event emitter","archived":false,"fork":false,"pushed_at":"2023-07-22T12:13:27.000Z","size":277,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-07T14:05:01.244Z","etag":null,"topics":["event","event-driven","event-emitter","javascript","pub-sub","pubsub","reactive","reactive-programming","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamiteru.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}},"created_at":"2022-11-17T18:13:20.000Z","updated_at":"2023-02-03T08:45:10.000Z","dependencies_parsed_at":"2022-11-17T22:30:32.098Z","dependency_job_id":null,"html_url":"https://github.com/yamiteru/ueve","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"yamiteru/ts-package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamiteru%2Fueve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamiteru%2Fueve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamiteru%2Fueve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamiteru%2Fueve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamiteru","download_url":"https://codeload.github.com/yamiteru/ueve/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237553118,"owners_count":19328909,"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":["event","event-driven","event-emitter","javascript","pub-sub","pubsub","reactive","reactive-programming","typescript"],"created_at":"2025-02-06T21:35:07.164Z","updated_at":"2025-10-21T21:31:11.154Z","avatar_url":"https://github.com/yamiteru.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"```bash\nyarn add ueve # npm install ueve\n```\n\n## Concept\n\nμEve is designed to be as low-level and unopinionated as possible so you can build your own abstractions on top of it. \n\nIt supports both sync and async modes. That means you can use sync to solve problems where sync fits the job best and async where async fits the job best.\n\n___\n\n## Performance\n\nThere are two aspects of performance that μEve is trying to solve.\n\n#### 1. Runtime performance\n\nThis one is obvious. It's what we usually think of when someone says performance.\n\nμEve is just a small wrapper around `Set`. Thanks to that the performance is very close to the native performance of `Set` and its methods.\n\nYou can't really go any faster (see [benchmark results](./benchmark.md)).\n\n#### 2. Library size\n\nWhat people often overlook is the size of a library. There are two major things that make bigger (in kb) libraries slower.\n\n1. When used in a browser the library needs to be downloaded before it can be parsed \n2. No matter where the library is used it needs to get parsed by the JS engine before it can be executed \n\nμEve is trying to solve these issues by opting out of OOP approach (which many other similar libraries use). In OOP the code for all class methods has to be downloaded and parsed first before it can be executed.\n\nInstead we create a simple object with private properties (with the help of symbols). The object is then passed into all of the methods as the first argument. This makes the methods importable and tree-shakeable.\n\nAll of this means that you download and parse only the code that ends up being executed.\n\n___\n\n## Examples\n\n1. [Simple counter](./examples/1-simple-counter.ts)\n2. [Input transformation](./examples/2-input-transformation.ts)\n3. [Input filtering](./examples/3-input-filtering.ts)\n4. [Sync vs Async](./examples/4-sync-vs-async.ts)\n\n___\n\n## API\n\n### `eve`\n\nIt creates an event with an optional `Transform` function. \n\nThe `Transform` function is used to transform `I` value from `pub` into a `O` value. \n\nYou can skip the value propagation by returning `undefined` inside the `Transform` function.\n\nThere are two versions of this function:\n1. Sync imported from `ueve/sync`\n2. Async imported from `ueve/async`\n\nIn the sync version the `Transform` function is a simple (sync) function. In the async version the `Transform` function is an async function which returns `Promise`.\n\n\n**This event just passes the input value to subscribers:**\n\n```ts\nconst message$ = eve\u003c{\n\tto: string;\n\tdate: Date;\n\tcontent: string;\n}\u003e();\n```\n\n**This one transforms the input value:**\n\n```ts\nconst click$\u003c[x: number, y: number]\u003e(\n\tasync ([x, y]) =\u003e ({ x, y })\n);\n```\n\n**And this one filters the input value:**\n\n```ts\nconst login$ = eve\u003cUser\u003e(\n\tasync (v) =\u003e !(v%2) ? v: undefined\n);\n```\n\n### `sub`\n\nIt adds the `Subscriber` to the event.\n\nIt returns `uns` function which deletes the `Subscriber` from the event. \n\n```ts\nconst unsub = sub(\n\tmessage$, \n\t(v) =\u003e console.log(`${v.to} -\u003e ${v.content}`)\n);\n\n// later in the code\nunsub();\n```\n\n### `uns`\n\nIt deletes the `Subscriber` from the event.\n\nIn order to delete the same `Subscriber` you have to keep the reference to the function saved somewere yourself and use it both in `sub` and `uns`.\n\n### `pub`\n\nIt uses the `Transform` function to transform the input value and notify all subscribers using this transformed value.\n\nIf the `Transform` function returns `undefined` then no subscribers are notified.\n\nThere are two versions of this function:\n1. Sync imported from `ueve/sync`\n2. Async imported from `ueve/async`\n\nIn the sync version the `pub` function is a simple sync function. In the async version the `pub` function is an async function which returns `Promise` and has to be awaited.\n\n### `has`\n\nIt checks whether the event has the `Subscriber`.\n\n### `clr`\n\nIt deletes all subcribers from the event.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamiteru%2Fueve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamiteru%2Fueve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamiteru%2Fueve/lists"}