(name: string, data: { detail?: Record<keyof EventDetail, { type: any }>, bubbles?: boolean, cancelable?: boolean } = {})
| 7 | * @returns { ClassDecorator } |
| 8 | */ |
| 9 | const event = <EventDetail>(name: string, data: { detail?: Record<keyof EventDetail, { type: any }>, bubbles?: boolean, cancelable?: boolean } = {}): ClassDecorator => { |
| 10 | return (target: any) => { |
| 11 | if (!Object.prototype.hasOwnProperty.call(target, "metadata")) { |
| 12 | target.metadata = {}; |
| 13 | } |
| 14 | |
| 15 | const metadata = target.metadata; |
| 16 | if (!metadata.events) { |
| 17 | metadata.events = {}; |
| 18 | } |
| 19 | |
| 20 | const eventsMetadata = metadata.events; |
| 21 | if (!eventsMetadata[name]) { |
| 22 | data.bubbles = !!data.bubbles; |
| 23 | data.cancelable = !!data.cancelable; |
| 24 | eventsMetadata[name] = data; |
| 25 | } |
| 26 | }; |
| 27 | }; |
| 28 | |
| 29 | export default event; |
no outgoing calls
no test coverage detected