fix: maximum call stack size (#4674)

* fix: maximum call stack size
This commit is contained in:
vince
2024-10-18 14:24:39 +08:00
committed by GitHub
parent 6cd9937c03
commit c491b9e021
7 changed files with 37 additions and 197 deletions

View File

@@ -81,7 +81,6 @@
"dependencies": {
"@ctrl/tinycolor": "catalog:",
"@tanstack/vue-store": "catalog:",
"@vue/reactivity": "catalog:",
"@vue/shared": "catalog:",
"clsx": "catalog:",
"defu": "catalog:",

View File

@@ -5,7 +5,6 @@ export * from './inference';
export * from './letter';
export * from './merge';
export * from './nprogress';
export * from './reactivity';
export * from './state-handler';
export * from './to';
export * from './tree';

View File

@@ -1,26 +0,0 @@
import { isProxy, isReactive, isRef, toRaw } from '@vue/reactivity';
function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {
const objectIterator = (input: any): any => {
if (Array.isArray(input)) {
return input.map((item) => objectIterator(item));
}
if (isRef(input) || isReactive(input) || isProxy(input)) {
return objectIterator(toRaw(input));
}
if (input && typeof input === 'object') {
const result = {} as T;
for (const key in input) {
if (Object.prototype.hasOwnProperty.call(input, key)) {
result[key as keyof T] = objectIterator(input[key]);
}
}
return result;
}
return input;
};
return objectIterator(sourceObj);
}
export { deepToRaw };