{"name":"main-event","version":"1.0.3","author":{"name":"Alex Potsides","email":"alex@achingbrain.net"},"license":"Apache-2.0 OR MIT","_id":"main-event@1.0.3","maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"}],"homepage":"https://github.com/achingbrain/main-event#readme","bugs":{"url":"https://github.com/achingbrain/main-event/issues"},"dist":{"shasum":"93b2ade7ceb4bf138bcd5d7926d256c6fb888290","tarball":"http://registry-npm.ywwl.com/main-event/download/main-event-1.0.3.tgz","fileCount":20,"integrity":"sha512-LZ54F4Yijv6fKN6cBEKEvJV8MAejODQ92nAEMZF1RdOEoIMqJT+kLUqleIelXjh4A+yP+9wWSHJ2oC844xrgqg==","signatures":[{"sig":"MEYCIQDZL7Q1zA2SMiZJFP86sTqYK9/BCLjT3fr5uKLz+qUuFAIhALb1yhsTydOUkktI3SlO0Qw6chxiUf+M+WVBaJ2TZe6f","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/main-event@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":35634,"size":7909,"noattachment":false,"key":"/main-event/-/main-event-1.0.3.tgz"},"type":"module","types":"./dist/src/index.d.ts","browser":{"./dist/src/events.js":"./dist/src/events.browser.js"},"exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js","module-sync":"./src/index.js"}},"gitHead":"90f0af8aad6bdca451d7261e02651d9b9232ca3d","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github",["@semantic-release/git",{"assets":["CHANGELOG.md","package.json"]}]],"branches":["main"]},"scripts":{"docs":"aegir docs","lint":"aegir lint","test":"aegir test -f","build":"aegir build","clean":"aegir clean","release":"aegir release","dep-check":"aegir dep-check","doc-check":"aegir doc-check","test:node":"aegir test -t node --cov","test:chrome":"aegir test -t browser --cov","test:firefox":"aegir test -t browser -- --browser firefox","test:electron-main":"aegir test -t electron-main","test:chrome-webworker":"aegir test -t webworker","test:firefox-webworker":"aegir test -t webworker -- --browser firefox"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9b23d661-c589-4d8b-a79e-7467fe6e8f67"}},"repository":{"url":"git+https://github.com/achingbrain/main-event.git","type":"git"},"_npmVersion":"11.12.1","description":"Typed event emitters","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","react-native":{"./dist/src/events.js":"./dist/src/events.browser.js"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^47.1.2"},"_npmOperationalInternal":{"tmp":"tmp/main-event_1.0.3_1775824965371_0.3247691203413243","host":"s3://npm-registry-packages-npm-production"},"readme":"# main-event\n\n[![codecov](https://img.shields.io/codecov/c/github/achingbrain/main-event.svg?style=flat-square)](https://codecov.io/gh/achingbrain/main-event)\n[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/main-event/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/achingbrain/main-event/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> Typed event emitters\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nAdds types to the EventTarget class.\n\nHopefully this won't be necessary\nforever:\n\n- <https://github.com/microsoft/TypeScript/issues/28357>\n- <https://github.com/microsoft/TypeScript/issues/43477>\n- <https://github.com/microsoft/TypeScript/issues/299>\n- <https://www.npmjs.com/package/typed-events>\n- <https://www.npmjs.com/package/typed-event-emitter>\n- <https://www.npmjs.com/package/typed-event-target>\n- etc\n\nIn addition to types, a `safeDispatchEvent` method is available which\nprevents dispatching events that aren't in the event map, and a\n`listenerCount` method which reports the number of listeners that are\ncurrently registered for a given event.\n\n## Example\n\n```ts\nimport { TypedEventEmitter } from 'main-event'\nimport type { TypedEventTarget } from 'main-event'\n\ninterface EventTypes {\n  'test': CustomEvent<string>\n}\n\nconst target = new TypedEventEmitter<EventTypes>()\n\n// it's a regular EventTarget\nconsole.info(target instanceof EventTarget) // true\n\n// register listeners normally\ntarget.addEventListener('test', (evt) => {\n  // evt is CustomEvent<string>\n})\n\n// @ts-expect-error 'derp' is not in the event map\ntarget.addEventListener('derp', () => {})\n\n// use normal dispatchEvent method\ntarget.dispatchEvent(new CustomEvent('test', {\n  detail: 'hello'\n}))\n\n// use type safe dispatch method\ntarget.safeDispatchEvent('test', {\n  detail: 'world'\n})\n\n// report listener count\nconsole.info(target.listenerCount('test')) // 0\n\n// event emitters can be used purely as interfaces too\nfunction acceptTarget (target: TypedEventTarget<EventTypes>) {\n  // ...\n}\n```\n\n# Install\n\n```console\n$ npm i main-event\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make its exports available as `MainEvent` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/main-event/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://achingbrain.github.io/main-event>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/achingbrain/main-event/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/achingbrain/main-event/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1775824965504,"_cnpm_publish_time":1775824965504,"dist-tags":{"latest":"1.0.5"}}