Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
arbitrary-emitter
Advanced tools
Readme
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 30 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.