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

use-debounce

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-debounce - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9-beta

lib/cache.js

26

lib/index.js

@@ -6,25 +6,15 @@ 'use strict';

});
exports.useDebounce = undefined;
exports.useDebouncedCallback = exports.useDebounce = undefined;
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _cache = require('./cache');
var _react = require('react');
var _cache2 = _interopRequireDefault(_cache);
var useDebounce = exports.useDebounce = function useDebounce(value, delay) {
var _useState = (0, _react.useState)(value),
_useState2 = _slicedToArray(_useState, 2),
debouncedValue = _useState2[0],
setDebouncedValue = _useState2[1];
var _callback = require('./callback');
(0, _react.useEffect)(function () {
var handler = setTimeout(function () {
setDebouncedValue(value);
}, delay);
var _callback2 = _interopRequireDefault(_callback);
return function () {
clearTimeout(handler);
};
}, [value, delay]);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
return debouncedValue;
};
exports.useDebounce = _cache2.default;
exports.useDebouncedCallback = _callback2.default;
{
"name": "use-debounce",
"version": "0.0.8",
"version": "0.0.9-beta",
"description": "Debounce hook for react",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -1,17 +0,4 @@

import { useState, useEffect } from 'react';
import useDebounce from './cache';
import useDebouncedCallback from './callback';
export const useDebounce = (value, delay) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
}, [value, delay]);
return debouncedValue;
};
export { useDebounce, useDebouncedCallback };
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