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.2.0 to 0.3.0

8

arbitrary-emitter.js

@@ -39,7 +39,11 @@ 'use strict'

const link = links.get(key)
if (!key) return
if (!link) return
link.forEach(fn => fn())
}
return { add, addOnce, trigger }
function remove (key) {
links.delete(key)
}
return { add, addOnce, trigger, remove }
}
{
"name": "arbitrary-emitter",
"version": "0.2.0",
"version": "0.3.0",
"description": "Event emitter with Map/Set sugar",

@@ -5,0 +5,0 @@ "main": "arbitrary-emitter.js",

@@ -23,2 +23,3 @@ arbitrary-emitter

- [emitter.trigger](#emitter-trigger-api)
- [emitter.remove](#emitter-remove-api)
- [Testing](#testing)

@@ -72,2 +73,13 @@

<a name="emitter-remove-api"></a>
## emitter.remove(key)
Remove all listeners binded to `key`
```js
emitter.remove(obj)
```
<a name="testing"></a>

@@ -74,0 +86,0 @@ ## Testing

@@ -32,1 +32,15 @@ 'use strict'

})
test('remove', t => {
const emitter = ae()
const obj = {}
let control = 0
emitter.add(obj, () => ++control)
emitter.add(obj, () => ++control)
emitter.trigger(obj)
t.is(control, 2, 'control')
emitter.remove(obj)
emitter.trigger(obj)
t.is(control, 2, 'remove link from subscriptions')
t.end()
})
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