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.10.2 to 0.11.0

7

arbitrary-emitter.js

@@ -92,3 +92,10 @@ 'use strict'

}
},
listeners (key) {
const e = events.get(key)
if (!e) return []
else return e.listeners.slice(0).reverse()
}
}

@@ -95,0 +102,0 @@ }

2

package.json
{
"name": "arbitrary-emitter",
"version": "0.10.2",
"version": "0.11.0",
"description": "Event emitter with ES6 Map sugar for modern browsers and node.js",

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

@@ -89,2 +89,18 @@ arbitrary-emitter

<a name="emitter-listeners-api"></a>
### listeners(eventKey)
Returns a copy of the array of listeners for the event tagged `eventKey`
```js
const key = {}
const f1 = () => console.log('f1')
const f2 = () => console.log('f2')
emitter.on(key, f1)
emitter.on(key, f2)
emitter.listeners(key)[0] === f1 // true
emitter.listeners(key)[1] === f2 // true
```
<a name="testing"></a>

@@ -91,0 +107,0 @@ ## Testing

@@ -146,1 +146,25 @@ 'use strict'

})
test('get listeners', t => {
const emitter = ae()
const key = {}
const key2 = {}
let c1 = 0
let c2 = 0
const f1 = () => ++c1
const f2 = () => ++c2
emitter.on(key, f1)
emitter.on(key, f2)
emitter.on(key2, f2)
emitter.emit(key)
t.is(c1, 1)
t.is(c2, 1)
const list = emitter.listeners(key)
t.is(list[0], f1)
t.is(list[1], f2)
const list2 = emitter.listeners(key2)
t.is(list2[0], f2)
const other = emitter.listeners({})
t.is(other.length, 0)
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