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.
Run a piece of code whenever the javascript process stops/exits/quits. On browsers, nodejs, electron, react-native, workers, iframes. It also ensures that the exit-function is called only once.
You should use this module when your write a npm library where you dont know in which environments the users will run it.
unload
handle?When nodejs:
process.on('beforeExit');
process.on('exit');
process.on('SIGINT'); // catches ctrl+c event
process.on('uncaughtException'); // catches uncaught exceptions
When browser:
window.addEventListener('beforeunload'); // closing of normal browser-window
window.addEventListener('unload'); // closed inside of iframe
Installation:
npm install unload --save
Add a function which runs when the process exits:
var unload = require('unload');
unload.add(function(){
console.log('Ouch, I\'m dying.');
});
Add and remove the function (It will no longer run when the process exits):
var unload = require('unload');
var ret = unload.add(function(){
console.log('Ouch, I\'m dying.');
});
ret.remove(); // removes the event-handler
Run all previously added functions:
var unload = require('unload');
unload.add(function(){
console.log('Ouch, I\'m dying.');
});
unload.runAll();
Remove all added functions (They will no longer run when the process exits):
var unload = require('unload');
unload.add(function(){
console.log('Ouch, I\'m dying.');
});
unload.removeAll();
FAQs
Execute code when the js-process exits. On all javascript-environments
The npm package unload receives a total of 1,311,583 weekly downloads. As such, unload popularity was classified as popular.
We found that unload 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.