@tarsis/toolkit 0.6.4 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8957,6 +8957,9 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8957
8957
  maxTimeoutMetadataRef.current = null;
8958
8958
  }
8959
8959
  }, []);
8960
+ const cancel = React.useCallback(() => {
8961
+ clearTimers();
8962
+ }, [clearTimers]);
8960
8963
  const invokeCallback = React.useCallback(
8961
8964
  (args) => {
8962
8965
  clearTimers();
@@ -8967,7 +8970,7 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8967
8970
  React.useEffect(() => {
8968
8971
  return clearTimers;
8969
8972
  }, [clearTimers]);
8970
- return React.useCallback(
8973
+ const debounced = React.useCallback(
8971
8974
  (...args) => {
8972
8975
  const isNewCycle = timeoutRef.current === null;
8973
8976
  if (leading && isNewCycle) {
@@ -8994,6 +8997,7 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8994
8997
  },
8995
8998
  [delay, maxWait, leading, invokeCallback, callbackRef]
8996
8999
  );
9000
+ return Object.assign(debounced, { cancel });
8997
9001
  };
8998
9002
 
8999
9003
  const useUniversalLayoutEffect = typeof window === "undefined" ? React.useEffect : React.useLayoutEffect;
@@ -8955,6 +8955,9 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8955
8955
  maxTimeoutMetadataRef.current = null;
8956
8956
  }
8957
8957
  }, []);
8958
+ const cancel = useCallback(() => {
8959
+ clearTimers();
8960
+ }, [clearTimers]);
8958
8961
  const invokeCallback = useCallback(
8959
8962
  (args) => {
8960
8963
  clearTimers();
@@ -8965,7 +8968,7 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8965
8968
  useEffect(() => {
8966
8969
  return clearTimers;
8967
8970
  }, [clearTimers]);
8968
- return useCallback(
8971
+ const debounced = useCallback(
8969
8972
  (...args) => {
8970
8973
  const isNewCycle = timeoutRef.current === null;
8971
8974
  if (leading && isNewCycle) {
@@ -8992,6 +8995,7 @@ const useDebounce = (callback, delay, { maxWait, leading = false } = {}) => {
8992
8995
  },
8993
8996
  [delay, maxWait, leading, invokeCallback, callbackRef]
8994
8997
  );
8998
+ return Object.assign(debounced, { cancel });
8995
8999
  };
8996
9000
 
8997
9001
  const useUniversalLayoutEffect = typeof window === "undefined" ? React__default.useEffect : React__default.useLayoutEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarsis/toolkit",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },