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.
perfect-debounce
Advanced tools
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href]
An improved debounce function with Promise support.
trailing
and leading
behaviorInstall package:
# npm
npm install perfect-debounce
# yarn
yarn add perfect-debounce
# pnpm
pnpm add perfect-debounce
Import:
// ESM
import { debounce } from 'perfect-debounce'
// CommonJS
const { debounce } = require('perfect-debounce')
Debounce function:
const debounced = debounce(async () => {
// Some heavy stuff
}, 25)
When calling debounced
, it will wait at least for 25ms
as configured before actually calling our function. This helps to avoid multiple calls.
To avoid initial wait, we can set leading: true
option. It will cause function to be immediately called if there is no other call:
const debounced = debounce(async () => {
// Some heavy stuff
}, 25, { leading: true })
If executing async function takes longer than debounce value, duplicate calls will be still prevented a last call will happen. To disable this behavior, we can set trailing: false
option:
const debounced = debounce(async () => {
// Some heavy stuff
}, 25, { trailing: false })
corepack enable
(use npm i -g corepack
for Node.js < 16.10)pnpm install
pnpm dev
Made with 💛
Based on sindresorhus/p-debounce.
Published under MIT License.
v1.0.0
types
subpath export (#14)pnpm
(#13)FAQs
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href]
The npm package perfect-debounce receives a total of 1,157,094 weekly downloads. As such, perfect-debounce popularity was classified as popular.
We found that perfect-debounce 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
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.