Skip to content

Commit d3f1cb1

Browse files
committed
feat: used @pansy/shared isFunction
1 parent e395c0a commit d3f1cb1

File tree

10 files changed

+7
-20
lines changed

10 files changed

+7
-20
lines changed

hooks/useControllableValue/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
1616
},
1717
"dependencies": {
18+
"@pansy/shared": "^1.2.0",
1819
"@pansy/use-memoized-fn": "0.2.5",
1920
"@pansy/use-update": "0.2.4"
2021
},

hooks/useControllableValue/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, useRef } from 'react';
2-
import { isFunction } from '@pansy/hook-utils';
2+
import { isFunction } from '@pansy/shared';
33
import { useMemoizedFn } from '@pansy/use-memoized-fn';
44
import { useUpdate } from '@pansy/use-update';
55

hooks/useCookieState/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
1717
},
1818
"dependencies": {
19+
"@pansy/shared": "^1.2.0",
1920
"@pansy/use-memoized-fn": "0.2.5",
2021
"@types/js-cookie": "^2.x.x",
2122
"js-cookie": "^2.x.x"

hooks/useCookieState/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Cookies from 'js-cookie';
2+
import { isFunction } from '@pansy/shared';
23
import { useState } from 'react';
34
import { useMemoizedFn } from '@pansy/use-memoized-fn';
45

@@ -8,10 +9,6 @@ export interface Options extends Cookies.CookieAttributes {
89
defaultValue?: State | (() => State);
910
}
1011

11-
export function isFunction(obj: any): obj is Function {
12-
return typeof obj === 'function';
13-
}
14-
1512
export function useCookieState(cookieKey: string, options: Options = {}) {
1613
const [state, setState] = useState<State>(() => {
1714
const cookieValue = Cookies.get(cookieKey);

hooks/useMemoizedFn/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useMemo, useRef } from 'react';
2-
import { isFunction } from '@pansy/hook-utils';
32

43
type noop = (...args: any[]) => any;
54

hooks/useRequest/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
1717
},
1818
"dependencies": {
19+
"@pansy/shared": "^1.2.0",
1920
"@pansy/hook-utils": "0.3.0",
2021
"@pansy/use-creation": "0.1.4",
2122
"@pansy/use-latest": "0.2.4",

hooks/useRequest/src/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFunction } from '@pansy/hook-utils';
1+
import { isFunction } from '@pansy/shared';
22

33
import type { MutableRefObject } from 'react';
44
import type { FetchState, Options, PluginReturn, Service, Subscribe } from './types';

hooks/utils/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export {
1010
export { canUseDom } from './utils/canUseDom';
1111
export { useIsomorphicLayoutEffectWithTarget } from './utils/useIsomorphicLayoutEffectWithTarget';
1212
export { useDeepCompareEffectWithTarget } from './utils/useDeepCompareWithTarget';
13-
export { isFunction } from './utils/isFunction';
1413

1514
export { createDeepCompareEffect } from './createDeepCompareEffect';
1615

hooks/utils/src/utils/createUseStorageState.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react';
2+
import { isFunction } from '@pansy/shared';
23
import { useMemoizedFn } from '@pansy/use-memoized-fn';
34
import { useUpdateEffect } from '@pansy/use-update-effect';
45

@@ -16,10 +17,6 @@ export type FuncUpdater<T> = (previousState?: T) => T;
1617
export type StorageStateResult<T> = [T | undefined, (value?: T | FuncUpdater<T>) => void];
1718
export type StorageStateResultHasDefaultValue<T> = [T, (value?: T | FuncUpdater<T>) => void];
1819

19-
function isFunction<T>(obj: any): obj is T {
20-
return typeof obj === 'function';
21-
}
22-
2320
export function createUseStorageState(getStorage: () => Storage | undefined) {
2421
function useStorageState<T = any>(key: string, options?: Options<T>): StorageStateResult<T>;
2522

hooks/utils/src/utils/isFunction.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)