nanoevents
Advanced tools
Comparing version 1.0.7 to 1.0.8
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 1.0.8 | ||
* Reduce size (by Vladlen Grachev). | ||
## 1.0.7 | ||
@@ -5,0 +8,0 @@ * Reduce size (by Vladlen Grachev). |
21
index.js
@@ -52,8 +52,5 @@ ( | ||
emit: function emit (event) { | ||
// event variable is reused and repurposed, now it's an array of handlers | ||
event = this.events[event] | ||
if (!event || !event[0]) return // event[0] === Array.isArray(event) | ||
var args = event.slice.call(arguments, 1) | ||
event.slice().map(function (i) { | ||
var args = [].slice.call(arguments, 1) | ||
// Array.prototype.call() returns empty array if context is not array-like | ||
;[].slice.call(this.events[event] || []).filter(function (i) { | ||
i.apply(this, args) // this === global or window | ||
@@ -88,12 +85,10 @@ }) | ||
// event variable is reused and repurposed, now it's an array of handlers | ||
event = this.events[event] = this.events[event] || [] | ||
event.push(cb) | ||
(this.events[event] = this.events[event] || []).push(cb) | ||
return function () { | ||
// a.splice(i >>> 0, 1) === if (i !== -1) a.splice(i, 1) | ||
// -1 >>> 0 === 0xFFFFFFFF, max possible array length | ||
event.splice(event.indexOf(cb) >>> 0, 1) | ||
} | ||
this.events[event] = this.events[event].filter(function (i) { | ||
return i !== cb | ||
}) | ||
}.bind(this) | ||
} | ||
} |
{ | ||
"name": "nanoevents", | ||
"version": "1.0.7", | ||
"description": "Simple and tiny (115 bytes) event emitter library", | ||
"version": "1.0.8", | ||
"description": "Simple and tiny (101 bytes) event emitter library", | ||
"keywords": [ | ||
@@ -21,3 +21,8 @@ "EventEmitter", | ||
"node": ">=4.0.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} | ||
} |
@@ -6,3 +6,3 @@ # Nano Events | ||
* No Node.js [EventEmitter] compatibility. | ||
* Only 115 bytes (minified and gzipped). It uses [Size Limit] to control size. | ||
* Only 101 bytes (minified and gzipped). It uses [Size Limit] to control size. | ||
* `on` method returns `unbind` function. You don’t need to save | ||
@@ -9,0 +9,0 @@ callback to variable for `removeListener`. |
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
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
7609
102