Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@restart/hooks

Package Overview
Dependencies
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restart/hooks - npm Package Compare versions

Comparing version 0.4.15 to 0.4.16

11

cjs/useDebouncedCallback.js

@@ -8,2 +8,3 @@ "use strict";

var _useEventCallback = _interopRequireDefault(require("./useEventCallback"));
var _useWillUnmount = _interopRequireDefault(require("./useWillUnmount"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -38,2 +39,4 @@ /**

const lastArgsRef = (0, _react.useRef)(null);
// Use any to bypass type issue with setTimeout.
const timerRef = (0, _react.useRef)(0);
const handleCallback = (0, _useEventCallback.default)(fn);

@@ -49,2 +52,6 @@ const {

const timeout = (0, _useTimeout.default)();
(0, _useWillUnmount.default)(() => {
clearTimeout(timerRef.current);
isTimerSetRef.current = false;
});
return (0, _react.useMemo)(() => {

@@ -119,3 +126,3 @@ const hasMaxWait = !!maxWait;

isTimerSetRef.current = true;
setTimeout(timerExpired, wait);
timerRef.current = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTimeRef.current);

@@ -126,3 +133,3 @@ }

isTimerSetRef.current = true;
setTimeout(timerExpired, wait);
timerRef.current = setTimeout(timerExpired, wait);
}

@@ -129,0 +136,0 @@ return returnValueRef.current;

import { useMemo, useRef } from 'react';
import useTimeout from './useTimeout';
import useEventCallback from './useEventCallback';
import useWillUnmount from './useWillUnmount';

@@ -33,2 +34,4 @@ /**

const lastArgsRef = useRef(null);
// Use any to bypass type issue with setTimeout.
const timerRef = useRef(0);
const handleCallback = useEventCallback(fn);

@@ -44,2 +47,6 @@ const {

const timeout = useTimeout();
useWillUnmount(() => {
clearTimeout(timerRef.current);
isTimerSetRef.current = false;
});
return useMemo(() => {

@@ -114,3 +121,3 @@ const hasMaxWait = !!maxWait;

isTimerSetRef.current = true;
setTimeout(timerExpired, wait);
timerRef.current = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTimeRef.current);

@@ -121,3 +128,3 @@ }

isTimerSetRef.current = true;
setTimeout(timerExpired, wait);
timerRef.current = setTimeout(timerExpired, wait);
}

@@ -124,0 +131,0 @@ return returnValueRef.current;

2

package.json
{
"name": "@restart/hooks",
"version": "0.4.15",
"version": "0.4.16",
"main": "cjs/index.js",

@@ -5,0 +5,0 @@ "types": "cjs/index.d.ts",

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