Socket
Socket
Sign inDemoInstall

yaeti

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaeti

Yet Another EventTarget Implementation


Version published
Maintainers
1
Weekly downloads
656,606
decreased by-23.62%

Weekly downloads

Readme

Source

yaeti

Yet Another EventTarget Implementation.

The library exposes both the EventTarget interface and the Event interface.

Installation

$ npm install yaeti --save

Usage

var yaeti = require('yaeti');

// Custom class we want to make an EventTarget.
function Foo() {
    // Call EventTarget constructor
    yaeti.EventTarget.call(this);
}
// Inherit EventTarget prototype
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;

// Create an instance.
var foo = new Foo();

function listener1() {
    console.log('listener1');
}

function listener2() {
    console.log('listener2');
}
 
foo.addEventListener('bar', listener1);
foo.addEventListener('bar', listener2);
foo.removeEventListener('bar', listener1);

var event = new yaeti.Event('bar');

foo.dispatchEvent(event);

// Output:
// => "listener2"

API

yaeti.EventTarget interface

Implementation of the EventTarget interface.

ES5
function Foo() {
    yaeti.EventTarget.call(this);
}
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;
ES6
class Foo extends EventTarget () {
    constructor () {
        super();
    }
}

The interface implements the addEventListener, removeEventListener and dispatchEvent methods as defined by the W3C.

listeners read-only property

Returns an object whose keys are configured event types (String) and whose values are an array of listeners (functions) for those event types.

yaeti.Event interface

Implementation of the Event interface.

NOTE: Just useful in Node (the browser already exposes the native Event interface).

var event = new yaeti.Event('bar');

Author

Iñaki Baz Castillo

License

MIT

FAQs

Last updated on 10 Jan 2022

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