{"id":17419578,"url":"https://github.com/bendrucker/weakmap-event","last_synced_at":"2026-04-04T13:39:39.882Z","repository":{"id":54811993,"uuid":"38975852","full_name":"bendrucker/weakmap-event","owner":"bendrucker","description":"Associate geval events with an object","archived":false,"fork":false,"pushed_at":"2021-01-27T20:10:26.000Z","size":25,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-10T08:14:09.032Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bendrucker.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}},"created_at":"2015-07-12T19:58:22.000Z","updated_at":"2021-01-27T20:10:29.000Z","dependencies_parsed_at":"2022-08-14T03:31:36.311Z","dependency_job_id":null,"html_url":"https://github.com/bendrucker/weakmap-event","commit_stats":null,"previous_names":["eaze/weakmap-event"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fweakmap-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fweakmap-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fweakmap-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fweakmap-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bendrucker","download_url":"https://codeload.github.com/bendrucker/weakmap-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981263,"owners_count":21193145,"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-17T02:26:59.256Z","updated_at":"2026-04-04T13:39:39.843Z","avatar_url":"https://github.com/bendrucker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# weakmap-event [![tests](https://github.com/bendrucker/weakmap-event/workflows/tests/badge.svg)](https://github.com/bendrucker/weakmap-event/actions?query=workflow%3Atests)\n\n\u003e Associate [geval](https://github.com/Raynos/geval) events with a given object.\n\nAdapted from code in [Mercury](https://github.com/Raynos/mercury)'s examples.\n\n\n## Install\n\n```\n$ npm install --save weakmap-event\n```\n\n\n## Usage\n\n```js\nvar WeakmapEvent = require('weakmap-event')\n\nvar onClick = WeakmapEvent()\n\nvar obj1 = {}\nvar obj2 = {}\n\nonClick.listen(obj1, function(data) {\n  assert.equal(data, 'hello')\n})\nonClick.listen(obj2, function(data) {\n  assert.equal(data, 'goodbye')\n})\n\nonClick.broadcast(obj1, 'hello')\nonClick.broadcast(obj2, 'goodbye')\n```\n\n## API\n\n#### `WeakmapEvent()` -\u003e `event`\n\nCreates a new weak-mapped event interface.\n\n#### `event.broadcast(obj, value)` -\u003e `undefined`\n\nBroadcasts the value for listeners mapped to the object\n\n##### obj\n\n*Required*  \nType: `object`\n\nThe object to limit the broadcast to. Listeners on other objects will not be called.\n\n##### value\n\n*Required*  \nType: `any`\n\nThe value to broadcast to matched listeners.\n\n#### `event.listen(obj, listener)` -\u003e `function`\n\nListen on values emitted for a given object. Returns an `unlisten` function that will disable the listener when called.\n\n##### obj\n\n*Required*  \nType: `object`\n\nThe object to listen on.\n\n##### listener\n\n*Required*  \nType: `function`  \nArguments: `value`\n\nA listener function to be called when a value is broadcasted matching the object.\n\n#### `event.listen.toHash(observable, listener)` -\u003e `undefined`\n\nListen on an observable hash.\n\n##### observable\n\n*Required*  \nType: `function`\n\nAn observable hash like [observ-struct](https://github.com/raynos/observ-struct) or [observ-varhash](https://github.com/nrw/observ-varhash).\n\n##### listener\n\n*Required*  \nType: `function`  \nArguments: `value`\n\nA listener function to be called when a value is broadcasted matching a value from within the hash.\n\n\n#### `event.listen.toArray(observable, listener)` -\u003e `undefined`\n\nListen on an observable array.\n\n##### observable\n\n*Required*  \nType: `function`\n\nAn observable array from [observ-array](https://github.com/raynos/observ-array).\n\n##### listener\n\n*Required*  \nType: `function`  \nArguments: `value`\n\nA listener function to be called when a value is broadcasted matching a value from within the array.\n\n## License\n\nMIT © [Ben Drucker](http://bendrucker.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fweakmap-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendrucker%2Fweakmap-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fweakmap-event/lists"}