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

use-throttled-effect

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

use-throttled-effect - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

12

lib/index.js

@@ -10,7 +10,11 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var useThrottledEffect = exports.useThrottledEffect = function useThrottledEffect(callback, limit) {
// const [throttledValue, setThrottledValue] = useState(value);
var deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var lastRan = (0, _react.useRef)(Date.now());
(0, _react.useEffect)(function () {
console.log([limit].concat(_toConsumableArray(deps)));
var handler = setTimeout(function () {

@@ -26,3 +30,5 @@ if (Date.now() - lastRan.current >= limit) {

};
}, [callback, limit]);
};
}, [limit].concat(_toConsumableArray(deps)));
};
exports.default = useThrottledEffect;
{
"name": "use-throttled-effect",
"version": "0.0.3",
"version": "0.0.4",
"description": "Throttled effect hook for react",

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

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