Socket
Socket
Sign inDemoInstall

@whatwg-node/events

Package Overview
Dependencies
0
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @whatwg-node/events

Cross Platform Smart Event API Ponyfill


Version published
Weekly downloads
5.9M
increased by0.88%
Maintainers
1
Install size
4.36 kB
Created
Weekly downloads
 

Readme

Source

@whatwg-node/events

A ponyfill package for JavaScript DOM Events Standard. If your JavaScript environment doesn't implement this standard natively, this package automatically ponyfills the missing parts, and export them as a module.

Installation

yarn add @whatwg-node/events

Usage

import { Event, EventTarget } from '@whatwg-node/events'

const target = new EventTarget()
target.addEventListener('foo', (event: Event) => {
  console.log(event.type) // foo
})

target.dispatchEvent(new Event('foo'))

If your environment already implements these natively, this package will export the native ones automatically.

Custom Events

import { CustomEvent, EventTarget } from '@whatwg-node/events'

const target = new EventTarget()
target.addEventListener('foo', (event: CustomEvent) => {
  console.assert(event.detail.foo, 'bar')
})

// `detail` can take any value
target.dispatchEvent(new CustomEvent('foo', { detail: { foo: 'bar' } }))

API

The following classes are exported by this package:

FAQs

Last updated on 25 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc