bare-events
Advanced tools
Comparing version 2.0.0 to 2.1.0
25
index.js
@@ -33,2 +33,13 @@ const errors = require('./lib/errors') | ||
removeAll (ctx, name) { | ||
const list = [...this.list] | ||
this.list = [] | ||
for (let i = list.length - 1; i >= 0; i--) { | ||
ctx.emit('removeListener', name, list[i][0]) // Emit AFTER removing | ||
} | ||
if (this.list.length === 0) delete ctx._events[name] | ||
} | ||
emit (ctx, name, ...args) { | ||
@@ -124,2 +135,16 @@ const list = [...this.list] | ||
setMaxListeners (n) {} | ||
removeAllListeners (name) { | ||
if (arguments.length === 0) { | ||
for (const key of Reflect.ownKeys(this._events)) { | ||
if (key === 'removeListener') continue | ||
this.removeAllListeners(key) | ||
} | ||
this.removeAllListeners('removeListener') | ||
} else { | ||
const e = this._events[name] | ||
if (e !== undefined) e.removeAll(this, name) | ||
} | ||
return this | ||
} | ||
} | ||
@@ -126,0 +151,0 @@ |
{ | ||
"name": "bare-events", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Event emitters for JavaScript", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/holepunchto/bare-events.git" | ||
"url": "git+https://github.com/holepunchto/bare-events.git" | ||
}, | ||
@@ -18,0 +18,0 @@ "author": "Holepunch", |
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
16552
150