Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
command-queue-module
Advanced tools
Create simple command queue proxies for modules.
You can boost the initial load performance of a page by requesting some non-crucial scripts asynchronously, but at the same time you might need to queue some calls to these libraries early on.
A common example is event / error tracking - it's not necessary to start sending events right after load, but it's beneficial to start collecting them as early as possible.
This project enables you to create proxy module for any library with the exact same API as the original, but the method calls are stored as commands and invoked only after the actual implementation is loaded.
createCommandQueueModule(methodNames, loadCallback)
methodNames
Type: Array<string>
Array of method names that will be proxied by the command queue. Other methods will not be available neither before or after load.
loadCallback
Type: (onLoad: (actualModule) => void) => void
Callback called right after calling createCommandQueueModule
. It should accept onLoad
function as it's only argument.
onLoad
should be called with the actual module object when it's available.
import()
const createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
import('my-tracking-library').then(onLoad);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
<script>
tagconst createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
const script = document.createElement('script');
script.src = 'https://example.org/my-tracking-library.umd.js';
script.onload = () => {
onLoad(window.MyTrackingLibrary)
};
document.body.append(script);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
FAQs
Create command queue proxies for modules
We found that command-queue-module 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.