---
title: "NodeEventTarget | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface NodeEventTarget

The `NodeEventTarget` is a Node.js-specific extension to `EventTarget` that emulates a subset of the `EventEmitter` API.

#### Since[](#since)

v14.5.0

interface NodeEventTarget {  
    [addEventListener](#addeventlistener-1)(  
        type: string,  
        callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null,  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [addListener](#addlistener-1)(type: string, listener: (arg: any) \=> void): this;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [emit](#emit-1)(type: string, arg: any): boolean;  
    [eventNames](#eventnames-1)(): string\[\];  
    [getMaxListeners](#getmaxlisteners-1)(): number;  
    [listenerCount](#listenercount-1)(type: string): number;  
    [off](#off-1)(  
        type: string,  
        listener: (arg: any) \=> void,  
        options?: EventListenerOptions,  
    ): this;  
    [on](#on-1)(type: string, listener: (arg: any) \=> void): this;  
    [once](#once-1)(type: string, listener: (arg: any) \=> void): this;  
    [removeAllListeners](#removealllisteners-1)(type?: string): this;  
    [removeEventListener](#removeeventlistener-1)(  
        type: string,  
        callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null,  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [removeListener](#removelistener-1)(  
        type: string,  
        listener: (arg: any) \=> void,  
        options?: EventListenerOptions,  
    ): this;  
    [setMaxListeners](#setmaxlisteners-1)(n: number): void;  
}

#### Hierarchy

-   EventTarget
    -   NodeEventTarget

##### Index

### Methods[](#methods)

[addEventListener](#addeventlistener) [addListener](#addlistener) [dispatchEvent](#dispatchevent) [emit](#emit) [eventNames](#eventnames) [getMaxListeners](#getmaxlisteners) [listenerCount](#listenercount) [off](#off) [on](#on) [once](#once) [removeAllListeners](#removealllisteners) [removeEventListener](#removeeventlistener) [removeListener](#removelistener) [setMaxListeners](#setmaxlisteners)

## Methods[](#methods-1)

### addEventListener[](#addeventlistener)

-   addEventListener(  
        type: string,  
        callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null,  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-1)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Parameters
    
    -   type: string
    -   callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Inherited from EventTarget.addEventListener
    

### addListener[](#addlistener)

-   addListener(type: string, listener: (arg: any) \=> void): this[](#addlistener-1)
    
    Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API. The only difference between `addListener()` and `addEventListener()` is that `addListener()` will return a reference to the `EventTarget`.
    
    #### Parameters
    
    -   type: string
    -   listener: (arg: any) \=> void
    
    #### Returns this
    
    #### Since[](#since-1)
    
    v14.5.0
    

### dispatchEvent[](#dispatchevent)

-   dispatchEvent(event: Event): boolean[](#dispatchevent-1)
    
    The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
    
    #### Parameters
    
    -   event: Event
    
    #### Returns boolean
    
    Inherited from EventTarget.dispatchEvent
    

### emit[](#emit)

-   emit(type: string, arg: any): boolean[](#emit-1)
    
    Node.js-specific extension to the `EventTarget` class that dispatches the `arg` to the list of handlers for `type`.
    
    #### Parameters
    
    -   type: string
    -   arg: any
    
    #### Returns boolean
    
    `true` if event listeners registered for the `type` exist, otherwise `false`.
    
    #### Since[](#since-2)
    
    v15.2.0
    

### eventNames[](#eventnames)

-   eventNames(): string\[\][](#eventnames-1)
    
    Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered.
    
    #### Returns string\[\]
    
    #### Since[](#since-3)
    
    14.5.0
    

### getMaxListeners[](#getmaxlisteners)

-   getMaxListeners(): number[](#getmaxlisteners-1)
    
    Node.js-specific extension to the `EventTarget` class that returns the number of max event listeners.
    
    #### Returns number
    
    #### Since[](#since-4)
    
    v14.5.0
    

### listenerCount[](#listenercount)

-   listenerCount(type: string): number[](#listenercount-1)
    
    Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`.
    
    #### Parameters
    
    -   type: string
    
    #### Returns number
    
    #### Since[](#since-5)
    
    v14.5.0
    

### off[](#off)

-   off(  
        type: string,  
        listener: (arg: any) \=> void,  
        options?: EventListenerOptions,  
    ): this[](#off-1)
    
    Node.js-specific alias for `eventTarget.removeEventListener()`.
    
    #### Parameters
    
    -   type: string
    -   listener: (arg: any) \=> void
    -   `Optional`options: EventListenerOptions
    
    #### Returns this
    
    #### Since[](#since-6)
    
    v14.5.0
    

### on[](#on)

-   on(type: string, listener: (arg: any) \=> void): this[](#on-1)
    
    Node.js-specific alias for `eventTarget.addEventListener()`.
    
    #### Parameters
    
    -   type: string
    -   listener: (arg: any) \=> void
    
    #### Returns this
    
    #### Since[](#since-7)
    
    v14.5.0
    

### once[](#once)

-   once(type: string, listener: (arg: any) \=> void): this[](#once-1)
    
    Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`.
    
    #### Parameters
    
    -   type: string
    -   listener: (arg: any) \=> void
    
    #### Returns this
    
    #### Since[](#since-8)
    
    v14.5.0
    

### removeAllListeners[](#removealllisteners)

-   removeAllListeners(type?: string): this[](#removealllisteners-1)
    
    Node.js-specific extension to the `EventTarget` class. If `type` is specified, removes all registered listeners for `type`, otherwise removes all registered listeners.
    
    #### Parameters
    
    -   `Optional`type: string
    
    #### Returns this
    
    #### Since[](#since-9)
    
    v14.5.0
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener(  
        type: string,  
        callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null,  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-1)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Parameters
    
    -   type: string
    -   callback: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/) | null
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Inherited from EventTarget.removeEventListener
    

### removeListener[](#removelistener)

-   removeListener(  
        type: string,  
        listener: (arg: any) \=> void,  
        options?: EventListenerOptions,  
    ): this[](#removelistener-1)
    
    Node.js-specific extension to the `EventTarget` class that removes the `listener` for the given `type`. The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
    
    #### Parameters
    
    -   type: string
    -   listener: (arg: any) \=> void
    -   `Optional`options: EventListenerOptions
    
    #### Returns this
    
    #### Since[](#since-10)
    
    v14.5.0
    

### setMaxListeners[](#setmaxlisteners)

-   setMaxListeners(n: number): void[](#setmaxlisteners-1)
    
    Node.js-specific extension to the `EventTarget` class that sets the number of max event listeners as `n`.
    
    #### Parameters
    
    -   n: number
    
    #### Returns void
    
    #### Since[](#since-11)
    
    v14.5.0
