Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

got-events

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got-events

Simple events for simple objects. Three methods to rule'em all: `on`, `off`, `trigger`.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

got-events

Simple events for simple objects. Three methods to rule'em all: .on, .off, .trigger. Lots of fun.

Install (coming soon)

npm install --save got-events

Usage

Three options:

  1. Function:
var evHandler = require('got-events')();
  1. Extend object:
require('got-events').extend(simpleObject);

Optionally preserving old attributes:

require('got-events').extend(simpleObject, true);
  1. Singleton:
var evHandler = require('got-events').singleton;

Object methods

  • .on(eventName, callback)

    Adds a callback to an event.

    1. eventName: String or Array of strings.
    2. callback: Function.
  • .on(eventName, callbackId, callback)

    Adds a callback to an event, identified.

    1. eventName: String or Array of strings.
    2. callbackId: String.
    3. callback: Function.
  • .off(eventName)

    Clears the event's callback list.

    1. eventName: String or Array of strings.
  • .off(eventName, callback)

    Removes a callback from an event.

    1. eventName: String or Array of strings.
    2. callback: Function.
  • .off(eventName, callbackId)

    Removes an identified callback from an event.

    1. eventName: String or Array of strings.
    2. callbackId: String or Array of strings.
  • .trigger(eventName, data)

    Triggers an event with err = null.

    1. eventName: String or Array of strings.
    2. data: Anything.
  • .trigger(eventName, err, data...)

    Triggers an event.

    1. eventName: String or Array of strings.
    2. err: Error or Boolean.
    3. data...: Anything. Every argument from here will be passed to callback.

Other features

  • Wildcard event '*' fired on every trigger.

Keywords

FAQs

Package last updated on 23 Apr 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc