Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@testing-library/react": "^16.3.0",
"@types/lodash": "^4.17.20",
"@types/lodash-es": "^4.17.12",
"@types/mockjs": "^1.0.7",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dayjs": "^1.9.1",
"intersection-observer": "^0.12.0",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"react-fast-compare": "^3.2.2",
"resize-observer-polyfill": "^1.5.1",
"screenfull": "^5.0.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/hooks/src/useDebounceFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ import isDev from '../utils/isDev';

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

function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
export interface DebouncedFn<T extends noop> {
run: ((...args: Parameters<T>) => ReturnType<T> | undefined) & {
cancel: () => void;
flush: () => ReturnType<T> | undefined;
};
cancel: () => void;
flush: () => ReturnType<T> | undefined;
}

function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions): DebouncedFn<T> {
if (isDev) {
if (!isFunction(fn)) {
console.error(`useDebounceFn expected parameter is a function, got ${typeof fn}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useReactive/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef } from 'react';
import isPlainObject from 'lodash/isPlainObject';
import isPlainObject from 'lodash-es/isPlainObject';
import useCreation from '../useCreation';
import useUpdate from '../useUpdate';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { useState } from 'react';
import Mock from 'mockjs';
import isNumber from 'lodash/isNumber';
import isNumber from 'lodash-es/isNumber';
import { Button, Space } from 'antd';
import { useRequest } from 'ahooks';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DebouncedFunc, DebounceSettings } from 'lodash';
import debounce from 'lodash/debounce';
import type { DebouncedFunc, DebounceSettings } from 'lodash-es';
import debounce from 'lodash-es/debounce';
import { useEffect, useMemo, useRef } from 'react';
import type { Plugin } from '../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DebouncedFunc, ThrottleSettings } from 'lodash';
import throttle from 'lodash/throttle';
import type { DebouncedFunc, ThrottleSettings } from 'lodash-es';
import throttle from 'lodash-es/throttle';
import { useEffect, useRef } from 'react';
import type { Plugin } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useSelections/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObject from 'lodash/isPlainObject';
import isPlainObject from 'lodash-es/isPlainObject';
import useMemoizedFn from '../useMemoizedFn';
import { isFunction, isString } from '../utils';
import { useMemo, useState } from 'react';
Expand Down
13 changes: 11 additions & 2 deletions packages/hooks/src/useThrottleFn/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import throttle from 'lodash/throttle';
import throttle from 'lodash-es/throttle';
import { useMemo } from 'react';
import useLatest from '../useLatest';
import type { ThrottleOptions } from '../useThrottle/throttleOptions';
Expand All @@ -8,7 +8,16 @@ import isDev from '../utils/isDev';

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

function useThrottleFn<T extends noop>(fn: T, options?: ThrottleOptions) {
export interface ThrottledFn<T extends noop> {
run: ((...args: Parameters<T>) => ReturnType<T> | undefined) & {
cancel: () => void;
flush: () => ReturnType<T> | undefined;
};
cancel: () => void;
flush: () => ReturnType<T> | undefined;
}

function useThrottleFn<T extends noop>(fn: T, options?: ThrottleOptions): ThrottledFn<T> {
if (isDev) {
if (!isFunction(fn)) {
console.error(`useThrottleFn expected parameter is a function, got ${typeof fn}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/utils/lodash-polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce from 'lodash/debounce';
import debounce from 'lodash-es/debounce';

function isNodeOrWeb() {
const freeGlobal =
Expand Down
71 changes: 34 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading