Skip to content

Commit

Permalink
opt: opt utils.merge and utils.clone
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Nov 5, 2023
1 parent 841b51a commit ece5cca
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/common/utils/typeChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@ export function merge (target: any, source: any): void {
const sourceProp = source[key]
if (
isObject(sourceProp) &&
isObject(targetProp) &&
!isArray(sourceProp) &&
!isArray(targetProp)
isObject(targetProp)
) {
merge(targetProp, sourceProp)
} else {
if (isValid(source[key])) {
target[key] = source[key]
target[key] = clone(source[key])
}
}
}
}
}

export function clone<T> (target: T): T {
if (!isObject(target) || !isArray(target)) {
if (!isObject(target)) {
return target
}

Expand Down Expand Up @@ -69,7 +67,7 @@ export function isFunction<T = (...args: any) => any> (value: any): value is T {
}

export function isObject (value: any): value is object {
return (typeof value === 'object')
return (typeof value === 'object') && isValid(value)
}

export function isNumber (value: any): value is number {
Expand Down

0 comments on commit ece5cca

Please sign in to comment.