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.
emitters
Advanced tools
Readme
Fancy node-compatible event emitters, including bubbling and singleton ready events.
var emitters = require('emitters');
// Polyfill for a node-compatible EventEmitter.
var ee = new emitters.EventEmitter();
var count = 0
, counter = function (evt){
console.log("Count: "+(count++)+" because "+this+" fired "+evt);
};
// An emitter that auto-invokes listeners if the "ready" event has already occurred.
var re = new emitters.ReadyEmitter();
re.on('ready', counter);
// Fires the ready event unless already ready.
re.ready(true); // -> count == 1
// Invokes our callback because we're already ready.
re.on('ready', counter); // -> count == 2
// Or...
re.ready(counter); // -> count == 3
// A ChainedEmitter bubbles events to its parent.
var c1 = new emitters.ChainedEmitter(ee)
, c2 = new emitters.ChainedEmitter(c1)
, c3 = new emitters.ChainedEmitter()
;
// You can also get/set the parent emitter later.
c3.parentEmitter(c1);
// So we're bubbling from c2 -> c1, c3 -> c1, and c1 -> ee; let's listen in.
ee.on('bonk', counter);
c1.on('bonk', counter);
c2.on('bonk', counter);
c3.on('bonk', counter);
c2.emit('bonk'); // -> We see c2, c1, and ee all recieve events, putting our counter to 6.
// Event handlers can stop propagaion by returning false.
c1.on('bonk', function (){
console.log('STOP!');
return false;
});
c3.emit('bonk'); // -> c3 and c1 both have listeners who will get the event...
// But the second listener we just registered will end the bubbling. (Even if the
// listener were first, the rest of c1's listeners would be notified. Stopping
// propagation prevents the event from moving *up*.)
For usage in node.js, install it via npm: npm install emitters
.
A browser distribution is coming soon!
Coming soon — use the source, Luke!
Find a bug or want to contribute? Open a ticket (or fork the source!) on github. You're also welcome to send me email at dsc@less.ly.
emitters
was written by David Schoonover (in Coco, a dialect of CoffeeScript that compiles down to JavaScript). It is open-source software and freely available under the MIT License.
FAQs
Fancy node-compatible event emitters, including bubbling and singleton ready events.
The npm package emitters receives a total of 29 weekly downloads. As such, emitters popularity was classified as not popular.
We found that emitters 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.