arbitrary-emitter
Advanced tools
Comparing version 0.8.3 to 0.9.0
@@ -8,4 +8,4 @@ 'use strict' | ||
const size = triggers.size | ||
if (!size) return listeners.delete(lis.key) | ||
if (size === 1) { | ||
if (!size) listeners.delete(lis.key) | ||
else if (size === 1) { | ||
let fn | ||
@@ -70,9 +70,11 @@ triggers.forEach(f => { fn = f }) | ||
const al = arguments.length | ||
if (al === 1) return lis.launch0() | ||
if (al > 4) return lis.launch1(arguments[1], arguments[2]) | ||
let args = new Array(al - 1) | ||
for (let i = 1; i < al; ++i) { | ||
args[i - 1] = arguments[i] | ||
if (al === 1) lis.launch0() | ||
else if (al > 4) lis.launch1(arguments[1], arguments[2]) | ||
else { | ||
let args = new Array(al - 1) | ||
for (let i = 1; i < al; ++i) { | ||
args[i - 1] = arguments[i] | ||
} | ||
lis.launchX(args) | ||
} | ||
lis.launchX(args) | ||
}, | ||
@@ -87,3 +89,3 @@ | ||
let args = arguments[1] | ||
if (!Array.isArray(args)) { | ||
if (typeof args !== 'object') { | ||
throw new Error('arguments has wrong type') | ||
@@ -95,8 +97,4 @@ } | ||
off (key, action) { | ||
if (1 in arguments) { | ||
let lis = listeners.get(key) | ||
if (lis) lis.rm(action) | ||
} else { | ||
listeners.delete(key) | ||
} | ||
if (!(1 in arguments)) listeners.delete(key) | ||
else if (listeners.has(key)) listeners.get(key).rm(action) | ||
} | ||
@@ -103,0 +101,0 @@ } |
{ | ||
"name": "arbitrary-emitter", | ||
"version": "0.8.3", | ||
"version": "0.9.0", | ||
"description": "Event emitter with Map/Set sugar for modern browsers and node.js", | ||
@@ -5,0 +5,0 @@ "main": "arbitrary-emitter.js", |
Sorry, the diff of this file is not supported yet
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
12111
226