All Projects → primus → Eventemitter3

primus / Eventemitter3

Licence: mit
EventEmitter3 - Because there's also a number 2. And we're faster.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to Eventemitter3

Datash
Send and Receive files directly from your browser with end-to-end encryption
Stars: ✭ 178 (-92.87%)
Mutual labels:  browser
Atgmediabrowser
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Stars: ✭ 186 (-92.55%)
Mutual labels:  browser
Node Deep Extend
Recursive extend module
Stars: ✭ 191 (-92.35%)
Mutual labels:  browser
Render Media
Intelligently render media files in the browser
Stars: ✭ 181 (-92.75%)
Mutual labels:  browser
Lantern
基于Swift的高可用视图框架
Stars: ✭ 181 (-92.75%)
Mutual labels:  browser
Zl Fetch
A library that makes the Fetch API a breeze
Stars: ✭ 186 (-92.55%)
Mutual labels:  browser
Blocklike
Bridging the gap between block programming and JavaScript.
Stars: ✭ 177 (-92.91%)
Mutual labels:  browser
Device Detector Js
A precise user agent parser and device detector written in TypeScript
Stars: ✭ 193 (-92.27%)
Mutual labels:  browser
Node Webkitgtk
webkitgtk bindings for 🚀 Node.js
Stars: ✭ 185 (-92.59%)
Mutual labels:  browser
Speechtotext Websockets Javascript
SDK & Sample to do speech recognition using websockets in Javascript
Stars: ✭ 191 (-92.35%)
Mutual labels:  browser
Gopassbridge
A web extension for firefox and chrome to insert login credentials from gopass
Stars: ✭ 182 (-92.71%)
Mutual labels:  browser
Browser
🌍 Cross-platform Material design web browser
Stars: ✭ 184 (-92.63%)
Mutual labels:  browser
Yuzubrowser
Customizable browser for android
Stars: ✭ 188 (-92.47%)
Mutual labels:  browser
Hxphotopicker
图片/视频选择器 - 支持LivePhoto、GIF图片选择、3DTouch预览、在线下载iCloud上的资源、编辑图片/视频、浏览网络图片 功能 Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function
Stars: ✭ 2,363 (-5.4%)
Mutual labels:  browser
Browser Base
Modern and feature-rich web browser base based on Electron
Stars: ✭ 2,417 (-3.24%)
Mutual labels:  browser
Torrent Discovery
Discover BitTorrent and WebTorrent peers
Stars: ✭ 177 (-92.91%)
Mutual labels:  browser
Fingerprintjs
Browser fingerprinting library with the highest accuracy and stability.
Stars: ✭ 15,481 (+519.74%)
Mutual labels:  browser
Python Scripts
Collection of Various Python Script's.💻
Stars: ✭ 195 (-92.19%)
Mutual labels:  browser
Offline Qr Code
📱 Browser add-on allowing you to quickly generate a QR code offline with the URL of the open tab or other text!
Stars: ✭ 193 (-92.27%)
Mutual labels:  browser
Arewedistributedyet
Website + Community effort to unlock the peer-to-peer web at arewedistributedyet.com ⚡🌐🔑
Stars: ✭ 189 (-92.43%)
Mutual labels:  browser

EventEmitter3

Version npmBuild StatusCoverage StatusIRC channel

Sauce Test Status

EventEmitter3 is a high performance EventEmitter. It has been micro-optimized for various of code paths making this, one of, if not the fastest EventEmitter available for Node.js and browsers. The module is API compatible with the EventEmitter that ships by default with Node.js but there are some slight differences:

  • Domain support has been removed.
  • We do not throw an error when you emit an error event and nobody is listening.
  • The newListener and removeListener events have been removed as they are useful only in some uncommon use-cases.
  • The setMaxListeners, getMaxListeners, prependListener and prependOnceListener methods are not available.
  • Support for custom context for events so there is no need to use fn.bind.
  • The removeListener method removes all matching listeners, not only the first.

It's a drop in replacement for existing EventEmitters, but just faster. Free performance, who wouldn't want that? The EventEmitter is written in EcmaScript 3 so it will work in the oldest browsers and node versions that you need to support.

Installation

$ npm install --save eventemitter3

CDN

Recommended CDN:

https://unpkg.com/eventemitter3@latest/umd/eventemitter3.min.js

Usage

After installation the only thing you need to do is require the module:

var EventEmitter = require('eventemitter3');

And you're ready to create your own EventEmitter instances. For the API documentation, please follow the official Node.js documentation:

http://nodejs.org/api/events.html

Contextual emits

We've upgraded the API of the EventEmitter.on, EventEmitter.once and EventEmitter.removeListener to accept an extra argument which is the context or this value that should be set for the emitted events. This means you no longer have the overhead of an event that required fn.bind in order to get a custom this value.

var EE = new EventEmitter()
  , context = { foo: 'bar' };

function emitted() {
  console.log(this === context); // true
}

EE.once('event-name', emitted, context);
EE.on('another-event', emitted, context);
EE.removeListener('another-event', emitted, context);

Tests and benchmarks

This module is well tested. You can run:

  • npm test to run the tests under Node.js.
  • npm run test-browser to run the tests in real browsers via Sauce Labs.

We also have a set of benchmarks to compare EventEmitter3 with some available alternatives. To run the benchmarks run npm run benchmark.

Tests and benchmarks are not included in the npm package. If you want to play with them you have to clone the GitHub repository. Note that you will have to run an additional npm i in the benchmarks folder before npm run benchmark.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].