@aiszlab/relax 1.2.22 → 1.2.23
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.
|
@@ -16,7 +16,7 @@ const useCounter = (_a = { initialValue: 0, max: Infinity, min: 0 }) => {
|
|
|
16
16
|
setCount((prev) => Math.min(max, prev + step));
|
|
17
17
|
}, [max]);
|
|
18
18
|
const prev = useCallback((step = 1) => {
|
|
19
|
-
setCount((prev) => Math.max(prev - step));
|
|
19
|
+
setCount((prev) => Math.max(min, prev - step));
|
|
20
20
|
}, [min]);
|
|
21
21
|
const first = useCallback(() => {
|
|
22
22
|
setCount(min);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useEvent } from '../hooks/use-event';
|
|
2
1
|
interface Options {
|
|
3
2
|
/**
|
|
4
3
|
* @description
|
|
@@ -10,14 +9,14 @@ interface Options {
|
|
|
10
9
|
*/
|
|
11
10
|
readonly delay: number;
|
|
12
11
|
}
|
|
13
|
-
type Callable<T, R> =
|
|
12
|
+
type Callable<T, R> = (value: T) => R;
|
|
14
13
|
/**
|
|
15
14
|
* @author murukal
|
|
16
15
|
*
|
|
17
16
|
* @description
|
|
18
17
|
* debounce callback
|
|
19
18
|
*/
|
|
20
|
-
export declare const useDebounceCallback: <T, R>(_callable:
|
|
19
|
+
export declare const useDebounceCallback: <T, R>(_callable: Callable<T, R>, options?: Options) => {
|
|
21
20
|
next: (value: T) => void;
|
|
22
21
|
complete: () => void;
|
|
23
22
|
cancel: () => void;
|
package/dist/hooks/use-event.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useRef, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
const useEvent = (callable) => {
|
|
4
|
-
const ref = useRef();
|
|
4
|
+
const ref = useRef(callable);
|
|
5
5
|
ref.current = callable;
|
|
6
|
-
return useCallback((...args) => ref.current(...args), []);
|
|
6
|
+
return useCallback(((...args) => ref.current(...args)), []);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { useEvent };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useEvent } from '../hooks/use-event';
|
|
2
1
|
interface Options {
|
|
3
2
|
/**
|
|
4
3
|
* @description
|
|
@@ -10,14 +9,14 @@ interface Options {
|
|
|
10
9
|
*/
|
|
11
10
|
readonly duration: number;
|
|
12
11
|
}
|
|
13
|
-
type Callable<T, R> =
|
|
12
|
+
type Callable<T, R> = (value: T) => R;
|
|
14
13
|
/**
|
|
15
14
|
* @author murukal
|
|
16
15
|
*
|
|
17
16
|
* @description
|
|
18
17
|
* throttle callback
|
|
19
18
|
*/
|
|
20
|
-
export declare const useThrottleCallback: <T, R>(_callable:
|
|
19
|
+
export declare const useThrottleCallback: <T, R>(_callable: Callable<T, R>, options?: Options) => {
|
|
21
20
|
next: (value: T) => void;
|
|
22
21
|
complete: () => void;
|
|
23
22
|
cancel: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Arguments<T extends Function> = T extends (...args: infer A) => unknown ? A : never;
|