arbitrary-emitter
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -12,38 +12,38 @@ 'use strict' | ||
function add (key, method) { | ||
const link = links.get(key) || createNewLink(key) | ||
link.add(method) | ||
let isSubscribed = true | ||
return () => { | ||
if (isSubscribed) { | ||
link.delete(method) | ||
isSubscribed = false | ||
return { | ||
add (key, method) { | ||
const link = links.get(key) || createNewLink(key) | ||
link.add(method) | ||
let isSubscribed = true | ||
return () => { | ||
if (isSubscribed) { | ||
link.delete(method) | ||
isSubscribed = false | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
function addOnce (key, method) { | ||
const link = links.get(key) || createNewLink(key) | ||
const wrap = {} | ||
const fn = () => { | ||
method() | ||
wrap.remove() | ||
} | ||
link.add(fn) | ||
wrap.remove = () => { | ||
link.delete(fn) | ||
} | ||
} | ||
addOnce (key, method) { | ||
const link = links.get(key) || createNewLink(key) | ||
const wrap = {} | ||
const fn = () => { | ||
method() | ||
wrap.remove() | ||
} | ||
link.add(fn) | ||
wrap.remove = () => { | ||
link.delete(fn) | ||
} | ||
}, | ||
function trigger (key) { | ||
const link = links.get(key) | ||
if (!link) return | ||
link.forEach(fn => fn()) | ||
} | ||
trigger (key) { | ||
const link = links.get(key) | ||
if (!link) return | ||
link.forEach(fn => fn()) | ||
}, | ||
function remove (key) { | ||
links.delete(key) | ||
remove (key) { | ||
links.delete(key) | ||
} | ||
} | ||
return { add, addOnce, trigger, remove } | ||
} |
{ | ||
"name": "arbitrary-emitter", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Event emitter with Map/Set sugar", | ||
@@ -5,0 +5,0 @@ "main": "arbitrary-emitter.js", |
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
83