Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
For when you just want to listen to decent events and then do something...
Emitit is abstraction on top of the DOMs native event-API. This feels to be necessary, because of weird-ish DOM-behaviour (Opinion). What you want to is to abstract events, listen for them and then act on them and specific data, not whole DOM-objects. Also this module guides the user gently to bind events as low as possible for performance reasons. While we are at it we can add CSS on a per node basis, forcibly preventing defaults, such as user-select.
For convenience the module can be called in a script tag without requiring or including it explicitly. This works after including the JS-file in the header of the HTML-document. This is because the node-style JS is build with browserify and attached to the global window
object.
Pass in options into the constructor and be ready to listen to events.
npm install emitit
# and require it in your own browserify build
or
<!DOCTYPE html>
<html>
<head>
<script src="../dist/emitter.min.js" charset="utf-8"></script>
</head>
<body>
<div class="container">
<div class="emitter boxes">
<div class="emitter square over">over</div>
<div class="emitter square click">click</div>
</div>
</div>
<script type="text/javascript">
// bind all target boxes through css electors
var opts = {
targets: [
// '.emitter.square', // proof that dupes will be filtered
'.emitter.square.over',
'.emitter.square.click'
],
eventNames: ['click'], //required, no default fallback
emitMessage: 'hello',
// deffered: false, // speed deferrance default: false
queryRoot: document.body,
// allowDupes: false,
// allowToggle: true,
preventDefaults: [
{ property:'user-select', value: 'none'}
],
// map: [
// {mapTarget: '.emitter.square.up', eventName: 'mouseup'},
// {mapTarget: '.emitter.square.down', eventName: 'mousedown'}
// ]
}
var emitter = new Emitter(opts);
emitter.on('hello', function() {
console.log('hello from emitter 1');
})
emitter.on('error', function() {
console.log(err);
})
emitter.emit('hello')
</script>
</body>
</html>
FAQs
Browser event emitter the node way.
The npm package emitit receives a total of 2 weekly downloads. As such, emitit popularity was classified as not popular.
We found that emitit 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.