Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 467 Bytes

prefer-event-target.md

File metadata and controls

19 lines (13 loc) · 467 Bytes

Pattern: Use of Node.js-specific EventEmitter

Issue: -

Description

Using EventTarget instead of EventEmitter reduces bundle size and improves cross-platform compatibility since EventTarget is available in browsers, Deno, and Node.js, while EventEmitter is Node.js-specific.

Examples

Example of incorrect code:

class Foo extends EventEmitter {}

Example of correct code:

class Foo extends EventTarget {}