component-emitter
Advanced tools
Comparing version 1.1.3 to 1.2.0
1.2.0 / 2014-02-12 | ||
================== | ||
* prefix events with `$` to support object prototype method names | ||
1.1.3 / 2014-06-20 | ||
================== | ||
* republish for npm | ||
* add LICENSE file | ||
1.1.2 / 2014-02-10 | ||
@@ -3,0 +14,0 @@ ================== |
15
index.js
@@ -45,3 +45,3 @@ | ||
this._callbacks = this._callbacks || {}; | ||
(this._callbacks[event] = this._callbacks[event] || []) | ||
(this._callbacks['$' + event] = this._callbacks['$' + event] || []) | ||
.push(fn); | ||
@@ -62,7 +62,4 @@ return this; | ||
Emitter.prototype.once = function(event, fn){ | ||
var self = this; | ||
this._callbacks = this._callbacks || {}; | ||
function on() { | ||
self.off(event, on); | ||
this.off(event, on); | ||
fn.apply(this, arguments); | ||
@@ -99,3 +96,3 @@ } | ||
// specific event | ||
var callbacks = this._callbacks[event]; | ||
var callbacks = this._callbacks['$' + event]; | ||
if (!callbacks) return this; | ||
@@ -105,3 +102,3 @@ | ||
if (1 == arguments.length) { | ||
delete this._callbacks[event]; | ||
delete this._callbacks['$' + event]; | ||
return this; | ||
@@ -133,3 +130,3 @@ } | ||
var args = [].slice.call(arguments, 1) | ||
, callbacks = this._callbacks[event]; | ||
, callbacks = this._callbacks['$' + event]; | ||
@@ -156,3 +153,3 @@ if (callbacks) { | ||
this._callbacks = this._callbacks || {}; | ||
return this._callbacks[event] || []; | ||
return this._callbacks['$' + event] || []; | ||
}; | ||
@@ -159,0 +156,0 @@ |
{ | ||
"name": "component-emitter", | ||
"description": "Event emitter", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
"devDependencies": { | ||
@@ -21,3 +22,4 @@ "mocha": "*", | ||
"test": "make test" | ||
} | ||
}, | ||
"files": ["index.js", "LICENSE"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7114
5
136