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

use-debouncy

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-debouncy - npm Package Compare versions

Comparing version 1.9.3 to 2.0.0

lib/e2e/browser.test.d.ts

21

CHANGELOG.md

@@ -0,1 +1,22 @@

# [2.0.0](https://github.com/eavam/use-debouncy/compare/v1.9.3...v2.0.0) (2020-07-02)
### Bug Fixes
* add e2e tests in release workflow ([23928e3](https://github.com/eavam/use-debouncy/commit/23928e35dbb23d1a7c43a713f74c8061b86c6691))
* add newline at end gitignore ([c66ba7f](https://github.com/eavam/use-debouncy/commit/c66ba7f6ce012ebc50e897f92a8debf24827b17d))
### Features
* add e2e tests ([34cc610](https://github.com/eavam/use-debouncy/commit/34cc610a4f01affafa58d5d643094aa5a60c650c))
* changed hook for minimize useEffect calls ([26c608a](https://github.com/eavam/use-debouncy/commit/26c608aa27dfc24ab31e78d53313d5c8829a217f))
### BREAKING CHANGES
* Change track first mount call.
setTimeout reference moved in lexical scope.
The call happens clearTimeout with every deps update.
## [1.9.3](https://github.com/eavam/use-debouncy/compare/v1.9.2...v1.9.3) (2020-07-01)

@@ -2,0 +23,0 @@

2

lib/index.d.ts
import { EffectCallback, DependencyList } from 'react';
/**
*
* @param fn - Callback called on debounce.
* @param fn - Debounce callback.
* @param wait - Number of milliseconds to delay.

@@ -6,0 +6,0 @@ * @param deps - Array values that the debounce depends (like as useEffect).

@@ -1,2 +0,2 @@

import{useRef as n,useEffect as t}from"react";var o=t,i=function(n){n&&clearTimeout(n)};export default function(t,r,u){var c=r||0,f=u||[],e=n([void 0,t]);o((function(){e.current[1]=t}),[t]),o((function(){var n=e.current;i(n[0]),n[0]=setTimeout((function(){n[1]()}),c)}),f),o((function(){var n=e.current;return i(n[0]),function(){i(n[0])}}),[])}
import{useRef as t,useEffect as n}from"react";export default function(o,i,r){var u=i||0,e=r||[],f=t(o),c=t(!0);n((function(){f.current=o}),[o]),n((function(){if(!c.current){var t=setTimeout((function(){f.current()}),u);return function(){clearTimeout(t)}}c.current=!1}),e)}
//# sourceMappingURL=index.es.js.map

@@ -1,2 +0,2 @@

"use strict";var n=require("react"),t=n.useEffect,u=function(n){n&&clearTimeout(n)};module.exports=function(i,o,r){var c=o||0,e=r||[],f=n.useRef([void 0,i]);t((function(){f.current[1]=i}),[i]),t((function(){var n=f.current;u(n[0]),n[0]=setTimeout((function(){n[1]()}),c)}),e),t((function(){var n=f.current;return u(n[0]),function(){u(n[0])}}),[])};
"use strict";var t=require("react");module.exports=function(n,u,e){var i=u||0,r=e||[],c=t.useRef(n),o=t.useRef(!0);t.useEffect((function(){c.current=n}),[n]),t.useEffect((function(){if(!o.current){var t=setTimeout((function(){c.current()}),i);return function(){clearTimeout(t)}}o.current=!1}),r)};
//# sourceMappingURL=index.js.map
{
"name": "use-debouncy",
"version": "1.9.3",
"version": "2.0.0",
"author": "Egor Avakumov",

@@ -29,2 +29,4 @@ "description": "🌀Tiny (<150 bytes) debounce react effect hook with typescript support",

"test": "jest",
"test:unit": "jest --config=jest.unit.config.js",
"test:e2e": "jest --config=jest.e2e.config.js",
"build": "rollup -c",

@@ -52,3 +54,5 @@ "prebuild": "rimraf lib compile && tsc --outDir compile --declarationDir lib --declaration true"

"@types/jest": "26.0.3",
"@types/jest-in-case": "^1.0.2",
"@types/react": "16.9.38",
"@types/react-dom": "16.9.8",
"@typescript-eslint/eslint-plugin": "3.5.0",

@@ -65,8 +69,13 @@ "@typescript-eslint/parser": "3.5.0",

"jest": "26.1.0",
"jest-in-case": "1.0.2",
"jest-playwright-preset": "1.2.0",
"parcel": "1.12.4",
"playwright": "1.1.1",
"prettier": "2.0.5",
"pretty-quick": "2.0.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-test-renderer": "16.13.1",
"rimraf": "3.0.2",
"rollup": "2.18.1",
"rollup": "2.18.2",
"rollup-plugin-terser": "6.1.0",

@@ -73,0 +82,0 @@ "semantic-release": "17.1.1",

@@ -31,3 +31,3 @@ # useDebouncy

### Try in [codesandbox](https://codesandbox.io/s/example-use-debouncy-ynfuq?expanddevtools=1&fontsize=14&theme=dark)
### [Demo codesandbox](https://codesandbox.io/s/example-use-debouncy-ynfuq?expanddevtools=1&fontsize=14&theme=dark)

@@ -52,1 +52,19 @@ ```tsx

```
## API Reference
### useDebouncy
```typescript
useDebouncy(
fn: () => (void | (() => void | undefined)),
wait?: number,
deps?: any[],
): void
```
| Prop | Required | Default | Description |
| ---- | -------- | ------- | ----------------------------------------------------------- |
| fn | ✓ | | Debounce callback. |
| wait | | `0` | Number of milliseconds to delay. |
| deps | | `[]` | Array values that the debounce depends (like as useEffect). |

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