New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

perfect-debounce

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfect-debounce - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

4

dist/index.d.ts

@@ -17,3 +17,3 @@ interface DebounceOptions {

@param fn - Promise-returning/async function to debounce.
@param wait - Milliseconds to wait before calling `fn`.
@param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
@returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.

@@ -33,4 +33,4 @@ @example

*/
declare function debounce<ArgumentsType extends unknown[], ReturnType>(fn: (...args: ArgumentsType) => PromiseLike<ReturnType> | ReturnType, wait: number, options?: DebounceOptions): (...args: any[]) => Promise<unknown>;
declare function debounce<ArgumentsType extends unknown[], ReturnType>(fn: (...args: ArgumentsType) => PromiseLike<ReturnType> | ReturnType, wait?: number, options?: DebounceOptions): (...args: any[]) => Promise<unknown>;
export { DebounceOptions, debounce };
{
"name": "perfect-debounce",
"version": "0.1.1",
"version": "0.1.2",
"description": "",

@@ -21,10 +21,2 @@ "repository": "unjs/perfect-debounce",

],
"scripts": {
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
"prepack": "unbuild",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "vitest run --coverage"
},
"dependencies": {},

@@ -41,3 +33,12 @@ "devDependencies": {

"vitest": "latest"
}
}
},
"packageManager": "pnpm@6.32.3",
"scripts": {
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
"test": "vitest run --coverage"
},
"readme": "# perfect-debounce\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n[![Codecov][codecov-src]][codecov-href]\n\n> An improved debounce function with Promise support.\n\n- Well tested debounce implementation\n- Native Promise support\n- Avoid duplicate calls while promise is being resolved\n- Configurable `trailing` and `leading` behavior\n\n## Usage\n\nInstall package:\n\n```sh\n# npm\nnpm install perfect-debounce\n\n# yarn\nyarn install perfect-debounce\n\n# pnpm\npnpm install perfect-debounce\n```\n\nImport:\n\n```js\n// ESM\nimport { debounce } from 'perfect-debounce'\n\n// CommonJS\nconst { debounce } = require('perfect-debounce')\n```\n\nDebounce function:\n\n```js\nconst debounced = debounce(async () => {\n // Some heavy stuff\n}, 25)\n```\n\nWhen calling `debounced`, it will wait at least for `25ms` as configured before actually calling our function. This helps to avoid multiple calls.\n\nTo avoid initial wait, we can set `leading: true` option. It will cause function to be immediately called if there is no other call:\n\n```js\nconst debounced = debounce(async () => {\n // Some heavy stuff\n}, 25, { leading: true })\n```\n\nIf 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:\n\n```js\nconst debounced = debounce(async () => {\n // Some heavy stuff\n}, 25, { trailing: false })\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with 💛\n\nBased on [sindresorhus/p-debounce](https://github.com/sindresorhus/p-debounce).\n\nPublished under [MIT License](./LICENSE).\n\n<!-- Badges -->\n[npm-version-src]: https://img.shields.io/npm/v/perfect-debounce?style=flat-square\n[npm-version-href]: https://npmjs.com/package/perfect-debounce\n\n[npm-downloads-src]: https://img.shields.io/npm/dm/perfect-debounce?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/perfect-debounce\n\n[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/perfect-debounce/ci/main?style=flat-square\n[github-actions-href]: https://github.com/unjs/perfect-debounce/actions?query=workflow%3Aci\n\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/perfect-debounce/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/perfect-debounce\n"
}

@@ -70,4 +70,4 @@ # perfect-debounce

- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
- Install dependencies using `yarn install`
- Run interactive tests using `yarn dev`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`

@@ -74,0 +74,0 @@ ## License

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc