
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
arbitrary-emitter
Advanced tools
ES6 Map based event emitter in ~350 bytes
Arbitrary-emitter stores listeners in ES6 maps, so you can use any kind of value as key for your events
const emitter = arbitraryEmitter()
const key = {}
emitter.on(key, () => doSomething())
// will `doSomething`
emitter.emit(key)
on
, off
, once
and emit
)Install with npm or yarn, clone the repo or download and extract the zip. Then import or insert it as script tag.
Adds the handler
function to the event tagged with key
. key
can be any type of value. Every handler will be added once, despite the number of times it was added to the event. Handlers are invoked in the order they were added.
const key = {}
emitter.on(key, () => doSomething())
emitter.emit(key) // will `doSomething`
Same as on
, but listener
will be triggered just once, then it will be removed.
const key = {}
emitter.once(key, () => doSomethingOnce())
emitter.emit(key) // will `doSomethingOnce`
emitter.emit(key) // won't do anything
Invoke all handlers tagged with key
, passing the rest of the arguments
emitter.on('test', (opts) => console.log(opts.test))
const options = { test: 'Testing!' }
emitter.emit('test', options) // => 'Testing!'
key
but no handler
is passed the event will be removedkey
and handler
are passed as arguments just the handler will be removed from the eventemitter.off(key, action) // will remove action from listeners
emitter.off(key) // will remove all the listeners tagged with `key`, and the tag itself
Create and return an array with all the handlers for the event tagged with key
const f1 = () => alert('hi')
const f2 = () => alert('ho')
emitter.on('a', f1)
emitter.on('a', f2)
emitter.emitters()
// ==> [f1, f2]
npm test
© 2020 Jacobo Tabernero - Released under MIT License
FAQs
Map based event emitter in ~350 bytes
The npm package arbitrary-emitter receives a total of 0 weekly downloads. As such, arbitrary-emitter popularity was classified as not popular.
We found that arbitrary-emitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.