Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace lodash to lodash-es #211 #217

Closed
wants to merge 10 commits into from
6 changes: 3 additions & 3 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"type": "tsc -d"
},
"dependencies": {
"@vue/devtools-api": "^6.5.0",
"@types/js-cookie": "^3.0.1",
"@vue/devtools-api": "^6.5.0",
"js-cookie": "^3.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"qs": "^6.11.0",
"query-string": "^7.1.1",
"screenfull": "^5.0.0"
},
"peerDependencies": {
"peerDependencies": {
"vue": "^3.2.25"
},
"repository": "https://github.com/InhiblabCore/vue-hooks-plus",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useDebounceFn/index.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'

export interface DebounceOptions {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useEventEmitter/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cloneDeep from 'lodash/cloneDeep'
import { cloneDeep } from 'lodash-es'
import { ref, watchEffect } from 'vue'

type SubscriptionParams<T = any> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref, computed, watchEffect, unref } from "vue";
import type { DebouncedFunc, DebounceSettings } from "lodash";
import debounce from "lodash/debounce";
import type { DebouncedFunc, DebounceSettings } from "lodash-es";
import { debounce } from "lodash-es";
import type { UseRequestPlugin } from "../types";

const useDebouncePlugin: UseRequestPlugin<unknown, unknown[]> = (
Expand Down
6 changes: 3 additions & 3 deletions packages/hooks/src/useRequest/plugins/useThrottlePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { computed, unref, watchEffect } from 'vue'
import { DebouncedFunc, ThrottleSettings } from 'lodash'
import throttle from 'lodash/throttle'
import { DebouncedFunc, ThrottleSettings } from 'lodash-es'
import { throttle } from 'lodash-es'
import { UseRequestPlugin } from '../types'

const useThrottlePlugin: UseRequestPlugin<unknown, unknown[]> = (
Expand Down Expand Up @@ -52,7 +52,7 @@ const useThrottlePlugin: UseRequestPlugin<unknown, unknown[]> = (
}

return {
name: "throttlePlugin",
name: 'throttlePlugin',
onCancel: () => {
throttledRef.value?.cancel()
},
Expand Down
8 changes: 4 additions & 4 deletions packages/hooks/src/useSetState/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ref, Ref, unref, UnwrapRef, readonly, DeepReadonly, UnwrapNestedRefs } from 'vue'
import merge from 'lodash/merge'
import { merge } from 'lodash-es'

type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>)

function useSetState<S extends Record<string, any>>(
initialState: UseSetStateType<S>,
): [
DeepReadonly<UnwrapNestedRefs<[S] extends [Ref<any>] ? S : Ref<UnwrapRef<S>>>>,
(patch: Record<string, any>, cover?: boolean) => void,
] {
DeepReadonly<UnwrapNestedRefs<[S] extends [Ref<any>] ? S : Ref<UnwrapRef<S>>>>,
(patch: Record<string, any>, cover?: boolean) => void,
] {
const getInitialState = () => unref(initialState)

const state = ref<S>(getInitialState() as S)
Expand Down
2 changes: 1 addition & 1 deletion 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'
import { onUnmounted, ref, computed } from 'vue'
import { UseThrottleOptions } from '../useThrottle'

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/utils/useDeepCompareWithTarget.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ref } from 'vue'
import isEqual from 'lodash/isEqual'
import { isEqual } from 'lodash-es'
import { EffectCallback } from './createEffectWithTarget'
import { DependencyList } from './depsAreSame'
import { BasicTarget } from './domTarget'
Expand Down
Loading