{"id":17321782,"url":"https://github.com/avoidwork/tiny-observable","last_synced_at":"2025-04-14T16:00:31.036Z","repository":{"id":58242928,"uuid":"47367457","full_name":"avoidwork/tiny-observable","owner":"avoidwork","description":"Tiny Observable for Client or Server, to be used with DOM elements or custom objects.","archived":false,"fork":false,"pushed_at":"2025-04-01T00:17:20.000Z","size":755,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T01:26:11.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avoidwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["avoidwork"]}},"created_at":"2015-12-03T23:29:36.000Z","updated_at":"2025-04-01T00:17:16.000Z","dependencies_parsed_at":"2023-12-19T03:08:50.008Z","dependency_job_id":"834eefe3-e76b-4682-a6f4-c6d66b3cc995","html_url":"https://github.com/avoidwork/tiny-observable","commit_stats":{"total_commits":121,"total_committers":2,"mean_commits":60.5,"dds":"0.28099173553719003","last_synced_commit":"2f335989d73de384b779ff172d3b3914fef5a6bf"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avoidwork%2Ftiny-observable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avoidwork%2Ftiny-observable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avoidwork%2Ftiny-observable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avoidwork%2Ftiny-observable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avoidwork","download_url":"https://codeload.github.com/avoidwork/tiny-observable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248913827,"owners_count":21182356,"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-10-15T13:39:34.826Z","updated_at":"2025-04-14T16:00:30.991Z","avatar_url":"https://github.com/avoidwork.png","language":"JavaScript","funding_links":["https://github.com/sponsors/avoidwork"],"categories":[],"sub_categories":[],"readme":"# Tiny Observable\n\nTiny Observable for Client or Server, to be used with DOM elements or custom objects.\n\n## Using the factory\n\n```javascript\nimport {observable} from \"tiny-observable\";\nconst observer = observable();\n\n// Hooking into every click event\nobserver.hook(document.querySelector(\"body\"), \"click\");\n\n// Capturing events, and redirecting\nobserver.on(\"click\", ev =\u003e customFunction(ev));\n```\n\n## Using the Class\n\n```javascript\nimport {Observable} from \"tiny-observable\";\nconst observer = Observable();\n```\n\n```javascript\nimport {Observable} from \"tiny-observable\";\nclass MyObservable extends Observable {}\n```\n\n## Testing\n\nTiny Observable has 100% code coverage with its tests.\n\n```console\n\u003e nyc mocha test/*.js\n\n\n\n  Observable\n    √ Will create a new observable\n    √ Will reassign limit with setMaxListeners()\n    √ Will dispatch events when empty\n    √ Will hook element dispatch of event\n    √ Will dispatch event\n    √ Will unhook element dispatch of event\n    √ Will add \u0026 remove event handlers to a hooked input\n    √ Will throw errors with bad inputs\n\n\n  8 passing (6ms)\n\n---------------------|---------|----------|---------|---------|---------------------------------------\nFile                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s\n---------------------|---------|----------|---------|---------|---------------------------------------\nAll files            |   95.83 |    76.71 |   86.95 |     100 |                                      \n tiny-observable.cjs |   95.83 |    76.71 |   86.95 |     100 | 18-24,38,58,63,89,114,127-139,154-155\n---------------------|---------|----------|---------|---------|---------------------------------------\n```\n\n## API\n\n### addListener(event, handler[, id, scope])\nAdds a listener for an event.\n\n### dispatch(event [, ...]);\nDispatches an event, with optional arguments.\n\n### emit(event [, ...]);\nDispatches an event, with optional arguments.\n\n### eventNames();\nReturns an Array of event names.\n\n### getMaxListeners();\nReturns the limit of listeners per event.\n\n### listenerCount(event);\nReturns the count of listeners per event; this does not relate to hooked objects or elements.\n\n### hook(object, event);\nHooks an event on an object or element.\n\n### id();\nReturns a random ID.\n\n### off(event, id);\nRemoves all, or a specific listener for an event.\n\n### on(event, handler[, id, scope])\nAdds a listener for an event.\n\n### once(event, handler[, id, scope])\nAdds a single execution event listener for an event.\n\n### rawListeners(event)\nReturns an Array of raw functions for an event.\n\n### removeAllListeners(event)\nRemoves all event listeners for an event.\n\n### removeListener(event, id)\nRemoves an event listener by id.\n\n### setMaxListeners(n);\nSets the limit of listeners per event.\n\n### unhook(object, event);\nUnhooks an event from an object or element.\n\n## License\nCopyright (c) 2023 Jason Mulligan\nLicensed under the BSD-3 license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favoidwork%2Ftiny-observable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favoidwork%2Ftiny-observable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favoidwork%2Ftiny-observable/lists"}