@anfenn/dync 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-YSKDP34Q.js → chunk-QA2TX54K.js} +15 -2
- package/dist/chunk-QA2TX54K.js.map +1 -0
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/storage/sqlite/helpers.ts +19 -1
- package/dist/chunk-YSKDP34Q.js.map +0 -1
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
|
@@ -132,10 +132,28 @@ const buildCondition = (condition: SQLiteCondition): BuiltCondition => {
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
export const cloneValue = <T>(value: T): T => {
|
|
135
|
+
// Fast path for null/undefined/primitives
|
|
136
|
+
if (value == null || typeof value !== 'object') return value;
|
|
137
|
+
|
|
138
|
+
// Fast path for flat objects (common case for SQLite records)
|
|
139
|
+
if (!Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype) {
|
|
140
|
+
const obj = value as Record<string, unknown>;
|
|
141
|
+
let isFlat = true;
|
|
142
|
+
for (const key in obj) {
|
|
143
|
+
const v = obj[key];
|
|
144
|
+
if (v !== null && typeof v === 'object') {
|
|
145
|
+
isFlat = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (isFlat) return { ...obj } as T;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Deep clone for arrays/nested objects
|
|
135
153
|
if (typeof globalThis.structuredClone === 'function') {
|
|
136
154
|
return globalThis.structuredClone(value);
|
|
137
155
|
}
|
|
138
|
-
return JSON.parse(JSON.stringify(value
|
|
156
|
+
return JSON.parse(JSON.stringify(value)) as T;
|
|
139
157
|
};
|
|
140
158
|
|
|
141
159
|
export const quoteIdentifier = (name: string): string => `"${name.replace(/"/g, '""')}"`;
|