Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
debouncing
Advanced tools
Debouncing and throttling library optimizes event handling by delaying or limiting function execution.
Debouncing and throttling library optimizes event handling by intelligently delaying or limiting function execution. This prevents overwhelming user interfaces and unnecessary server requests, especially for fast-paced events like scrolling, typing, or button clicks. Choose between debouncing for single, final execution after a pause, or throttling for consistent function calls within a set interval. Leverage this library to enhance performance and responsiveness in your web applications.
npm install debouncing --save
import { debounce, throttle } from "debouncing";
const onResize = (event) => {
console.log("height", window.innerHeight);
console.log("width", window.innerWidth);
};
/**
* In the debouncing technique, no matter how many times the user fires the
* event, the attached function will be executed only after the specified
* time once the user stops firing the event.
*
* Returns a function, that, as long as it continues to be invoked, will not
* be triggered. The function will be called after it stops being called for
* N milliseconds.
* @param {!Function} func The function to execute.
* @param {number=} timeout The timeout in milliseconds.
* @return {!Function} Returns a function, that, as long as it continues
* to be invoked, will not be triggered.
*/
window.addEventListener("resize", debounce(onResize, 250), false);
/**
* Throttling is a technique in which, no matter how many times the user
* fires the event, the attached function will be executed only once in a
* given time interval.
*
* Returns a function, that, as long as it continues to be invoked, will only
* trigger every N milliseconds.
* @param {!Function} func The function to execute.
* @param {number=} timeout The timeout in milliseconds.
* @return {!Function} Returns a function, that, as long as it continues
* to be invoked, will only trigger every N milliseconds.
*/
window.addEventListener("resize", throttle(onResize, 250), false);
FAQs
Debouncing and throttling library optimizes event handling by delaying or limiting function execution.
The npm package debouncing receives a total of 9,440 weekly downloads. As such, debouncing popularity was classified as popular.
We found that debouncing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.