Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arbitrary-emitter

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arbitrary-emitter - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

62

arbitrary-emitter.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc