Socket
Socket
Sign inDemoInstall

fbemitter

Package Overview
Dependencies
16
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 3.0.0-alpha.1

lib/EventEmitter.js

56

lib/BaseEventEmitter.js

@@ -10,15 +10,5 @@ /**

* @providesModule BaseEventEmitter
* @typechecks
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var EmitterSubscription = require('./EmitterSubscription');
var EventSubscriptionVendor = require('./EventSubscriptionVendor');
var emptyFunction = require('fbjs/lib/emptyFunction');
var invariant = require('fbjs/lib/invariant');
/**

@@ -37,4 +27,15 @@ * @class BaseEventEmitter

*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var EmitterSubscription = require('./EmitterSubscription');
var ErrorUtils = require('fbjs/lib/ErrorUtils');
var EventSubscriptionVendor = require('./EventSubscriptionVendor');
var emptyFunction = require('fbjs/lib/emptyFunction');
var invariant = require('fbjs/lib/invariant');
var BaseEventEmitter = (function () {
/**

@@ -104,4 +105,3 @@ * @constructor

* last listener that was invoked. This allows a developer to provide an event
* object that can remove the listener (or listener map) during the
* invocation.
* object that can remove the listener during the invocation.
*

@@ -112,12 +112,2 @@ * If it is called when not inside of an emitting cycle it will throw.

*
* @example
* var subscription = emitter.addListenerMap({
* someEvent: function(data, event) {
* console.log(data);
* emitter.removeCurrentListener();
* }
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
* emitter.emit('someEvent', 'def'); // does not log anything
*/

@@ -138,3 +128,3 @@

BaseEventEmitter.prototype.listeners = function listeners(eventType) /* TODO: Array<EventSubscription> */{
BaseEventEmitter.prototype.listeners = function listeners(eventType) {
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);

@@ -165,2 +155,3 @@ return subscriptions ? subscriptions.filter(emptyFunction.thatReturnsTrue).map(function (subscription) {

var keys = Object.keys(subscriptions);
var args;
for (var ii = 0; ii < keys.length; ii++) {

@@ -172,3 +163,11 @@ var key = keys[ii];

this._currentSubscription = subscription;
this.__emitToSubscription.apply(this, [subscription].concat(Array.prototype.slice.call(arguments)));
if (args == null) {
args = [subscription];
for (var i = 0, len = arguments.length; i < len; i++) {
args[i + 1] = arguments[i];
}
} else {
args[0] = subscription;
}
this.__emitToSubscription.apply(this, args);
}

@@ -191,3 +190,8 @@ }

BaseEventEmitter.prototype.__emitToSubscription = function __emitToSubscription(subscription, eventType) {
var args = Array.prototype.slice.call(arguments, 2);
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
// Note: internally we use ErrorUtils.applyWithGuard
// We should add some version of that to fbjs but for now we won't guard.
subscription.listener.apply(subscription.context, args);

@@ -194,0 +198,0 @@ };

@@ -8,7 +8,10 @@ /**

* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule EmitterSubscription
*
* @providesModule EmitterSubscription
* @typechecks
*/
/**
* EmitterSubscription represents a subscription with listener and context data.
*/
'use strict';

@@ -22,6 +25,2 @@

/**
* EmitterSubscription represents a subscription with listener and context data.
*/
var EmitterSubscription = (function (_EventSubscription) {

@@ -28,0 +27,0 @@ _inherits(EmitterSubscription, _EventSubscription);

@@ -10,7 +10,5 @@ /**

* @providesModule EventSubscription
* @typechecks
*
*/
'use strict';
/**

@@ -20,2 +18,3 @@ * EventSubscription represents a subscription to a particular event. It can

*/
'use strict';

@@ -22,0 +21,0 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -8,5 +8,6 @@ /**

* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @providesModule EventSubscriptionVendor
* @typechecks
* @noflow
*/

@@ -30,3 +31,2 @@

this._subscriptionsForType = {};
this._currentSubscription = null;
}

@@ -33,0 +33,0 @@

{
"name": "fbemitter",
"version": "2.1.1",
"version": "3.0.0-alpha.1",
"keywords": [

@@ -16,3 +16,3 @@ "clientside"

],
"main": "index.js",
"main": "lib/EventEmitter.js",
"repository": "facebook/emitter",

@@ -19,0 +19,0 @@ "scripts": {

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