@jelper/hooks 0.1.1 → 0.2.0
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.
- package/README.md +29 -1
- package/es/index.js +1654 -90
- package/lib/index.js +1650 -88
- package/package.json +9 -7
- package/types/index.d.ts +20 -0
- package/types/useAsync.d.ts +13 -0
- package/types/useBoolState.d.ts +2 -0
- package/types/useCreate.d.ts +2 -0
- package/types/useDebounce.d.ts +3 -0
- package/types/useInterval.d.ts +2 -0
- package/types/useIsUnmount.d.ts +2 -0
- package/types/useListener.d.ts +2 -0
- package/types/useMount.d.ts +2 -0
- package/types/useParamsState.d.ts +6 -0
- package/types/useResizeObserver.d.ts +1 -0
- package/types/useRtCb.d.ts +2 -0
- package/types/useRtEffect.d.ts +2 -0
- package/types/useRtRef.d.ts +2 -0
- package/types/useRtState.d.ts +6 -0
- package/types/useSafeCb.d.ts +2 -0
- package/types/useSafeState.d.ts +3 -0
- package/types/useThrottle.d.ts +10 -0
- package/types/useTimeout.d.ts +8 -0
- package/types/useUnmount.d.ts +2 -0
- package/types/useUpdateEffect.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jelper/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "react hooks helper",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
7
8
|
"keywords": [
|
|
8
9
|
"store",
|
|
9
10
|
"helper"
|
|
@@ -12,20 +13,21 @@
|
|
|
12
13
|
"package.json",
|
|
13
14
|
"README.md",
|
|
14
15
|
"es/**",
|
|
15
|
-
"lib/**"
|
|
16
|
+
"lib/**",
|
|
17
|
+
"types/**"
|
|
16
18
|
],
|
|
17
19
|
"publishConfig": {
|
|
18
20
|
"access": "public"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
|
-
"@jelper/builder": "0.1.
|
|
22
|
-
"@types/lodash": "~4.14.182",
|
|
23
|
+
"@jelper/builder": "0.1.17",
|
|
23
24
|
"@types/node": "~18.0.0",
|
|
24
|
-
"@types/react": "~18.2.17"
|
|
25
|
+
"@types/react": "~18.2.17",
|
|
26
|
+
"@types/lodash-es": "~4.17.8"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
+
"react": "~18.2.0",
|
|
30
|
+
"lodash-es": "~4.17.21"
|
|
29
31
|
},
|
|
30
32
|
"author": "apathyjade@outlook.com",
|
|
31
33
|
"license": "ISC",
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { default as useSafeState } from './useSafeState';
|
|
2
|
+
export { default as useSafeCb } from './useSafeCb';
|
|
3
|
+
export { default as useRtRef } from './useRtRef';
|
|
4
|
+
export { default as useRtState } from './useRtState';
|
|
5
|
+
export { default as useRtCb } from './useRtCb';
|
|
6
|
+
export { default as useRtEffect } from './useRtEffect';
|
|
7
|
+
export { default as useBoolState } from './useBoolState';
|
|
8
|
+
export { default as useParamsState } from './useParamsState';
|
|
9
|
+
export { default as useUpdateEffect } from './useUpdateEffect';
|
|
10
|
+
export { default as useIsUnmount } from './useIsUnmount';
|
|
11
|
+
export { default as useCreate } from './useCreate';
|
|
12
|
+
export { default as useMount } from './useMount';
|
|
13
|
+
export { default as useUnmount } from './useUnmount';
|
|
14
|
+
export { default as useThrottle } from './useThrottle';
|
|
15
|
+
export { default as useDebounce } from './useDebounce';
|
|
16
|
+
export { default as useAsync } from './useAsync';
|
|
17
|
+
export { default as useTimeout } from './useTimeout';
|
|
18
|
+
export { default as useInterval } from './useInterval';
|
|
19
|
+
export { default as useListener } from './useListener';
|
|
20
|
+
export { default as useResizeObserver } from './useResizeObserver';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Opt<T extends (...arg: any) => any, R> {
|
|
2
|
+
defParam?: Parameters<T>;
|
|
3
|
+
immediate?: boolean;
|
|
4
|
+
format?: (p: ReturnType<T>) => R;
|
|
5
|
+
catchParam?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const useAsync: <T extends (...arg: any) => Promise<any>, R extends Object>(asyncFn: T, opt?: Opt<T, R>) => {
|
|
8
|
+
data: R | null | undefined;
|
|
9
|
+
run: ReturnFn<(runParam?: Partial<Parameters<T>> | undefined) => Promise<void>>;
|
|
10
|
+
loading: boolean | undefined;
|
|
11
|
+
error: null | undefined;
|
|
12
|
+
};
|
|
13
|
+
export default useAsync;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useResizeObserver(dom: HTMLElement, cb: (dom: ResizeObserverEntry) => void): (() => void)[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Options<T> {
|
|
3
|
+
isEqual?: (a: T, b: T) => boolean;
|
|
4
|
+
}
|
|
5
|
+
export default function useRtState<T = any>(value: T, onChange?: (value: T) => void, opts?: Options<T>): (T | import("react").Dispatch<import("react").SetStateAction<T>>)[];
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThrottleSettings } from 'lodash-es';
|
|
2
|
+
/**
|
|
3
|
+
* 用于节流函数的钩子函数
|
|
4
|
+
* @param cb - 要节流的函数
|
|
5
|
+
* @param wait - 节流延迟时间,默认为0
|
|
6
|
+
* @param opts - 节流选项对象,默认为{}
|
|
7
|
+
* @returns 节流函数
|
|
8
|
+
*/
|
|
9
|
+
declare const useThrottle: <T extends (...args: any) => any>(cb: T, wait?: number, opts?: ThrottleSettings) => import("lodash-es").DebouncedFunc<(...arg: Parameters<T>) => void>;
|
|
10
|
+
export default useThrottle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useUpdateEffect(cb: () => void, deps: any[]): void;
|