Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Browser-friendly enhanced events fully compatible with standard node.js and coffee-script
Browser-friendly enhanced events fully compatible with standard node.js and coffee-script. It's modified from event-emitter mainly.
error
, newListener
and removeListener
events to keep compatible.$ npm install event-ex
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack
Node JS events Usage:
EventEmitter = require('event-ex')
inherits = require('inherits-ex')
# Demo the event object bubbling usage:
class MyDb
inherits MyDb, EventEmitter
get: (key)->
result = @emit 'getting', key
if isObject result
return if result.state is ABORT
return result.result if result.state is DONE
_get(key)
event-emitter usage:
var ee = require('event-ex/event-emitter');
var emitter = ee({}), listener;
emitter.on('test', listener = function (args) {
// …emitter logic
});
emitter.once('test', function (args) {
// …invoked only once(!)
//and can return result to emit.
this.result = 18;
});
//return the result is 18.
var result = emitter.emit('test', arg1, arg2/*…args*/); // Two above listeners invoked
emitter.emit('test', arg1, arg2/*…args*/); // Only first listener invoked
emitter.off('test', listener); // Removed first listener
emitter.emit('test', arg1, arg2/*…args*/); // No listeners invoked
Removes all listeners from given event emitter object
Whether object has some listeners attached to the object.
When name
is provided, it checks listeners for specific event name
var emitter = ee();
var hasListeners = require('event-emitter/has-listeners');
var listener = function () {};
hasListeners(emitter); // false
emitter.on('foo', listener);
hasListeners(emitter); // true
hasListeners(emitter, 'foo'); // true
hasListeners(emitter, 'bar'); // false
emitter.off('foo', listener);
hasListeners(emitter, 'foo'); // false
Pipes all events from source emitter onto target emitter (all events from source emitter will be emitted also on target emitter, but not other way).
Returns pipe object which exposes pipe.close
function. Invoke it to close configured pipe.
It works internally by redefinition of emit
method, if in your interface this method is referenced differently, provide its name (or symbol) with third argument.
Unifies event handling for two objects. Events emitted on emitter1 would be also emitter on emitter2, and other way back.
Non reversible.
var eeUnify = require('event-emitter/unify');
var emitter1 = ee(), listener1, listener3;
var emitter2 = ee(), listener2, listener4;
emitter1.on('test', listener1 = function () { });
emitter2.on('test', listener2 = function () { });
emitter1.emit('test'); // Invoked listener1
emitter2.emit('test'); // Invoked listener2
var unify = eeUnify(emitter1, emitter2);
emitter1.emit('test'); // Invoked listener1 and listener2
emitter2.emit('test'); // Invoked listener1 and listener2
emitter1.on('test', listener3 = function () { });
emitter2.on('test', listener4 = function () { });
emitter1.emit('test'); // Invoked listener1, listener2, listener3 and listener4
emitter2.emit('test'); // Invoked listener1, listener2, listener3 and listener4
FAQs
Browser-friendly enhanced events most compatible with standard node.js, it's powerful eventable ability.
The npm package events-ex receives a total of 27 weekly downloads. As such, events-ex popularity was classified as not popular.
We found that events-ex demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.