nicot 1.2.11 → 1.2.12
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/dist/index.cjs +30 -29
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +30 -29
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2106,29 +2106,33 @@ var CrudBase = class {
|
|
|
2106
2106
|
if (!await this.repo.exists({ where })) {
|
|
2107
2107
|
throw404();
|
|
2108
2108
|
}
|
|
2109
|
-
const
|
|
2110
|
-
if (!v || typeof v !== "object") return
|
|
2111
|
-
|
|
2112
|
-
|
|
2109
|
+
const isAtomicObject = (v) => {
|
|
2110
|
+
if (!v || typeof v !== "object") return true;
|
|
2111
|
+
if (v instanceof Date) return true;
|
|
2112
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v)) return true;
|
|
2113
|
+
if (ArrayBuffer.isView(v) || v instanceof ArrayBuffer) return true;
|
|
2114
|
+
return false;
|
|
2113
2115
|
};
|
|
2114
|
-
const
|
|
2116
|
+
const cloneForSnapshot = (v) => {
|
|
2115
2117
|
if (v == null) return v;
|
|
2116
2118
|
if (typeof v !== "object") return v;
|
|
2117
2119
|
if (v instanceof Date) return new Date(v.getTime());
|
|
2118
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v))
|
|
2120
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v))
|
|
2119
2121
|
return Buffer.from(v);
|
|
2120
|
-
|
|
2121
|
-
if (ArrayBuffer.isView(v)) {
|
|
2122
|
-
const ctor = v.constructor;
|
|
2123
|
-
return new ctor(v.slice?.() ?? v);
|
|
2124
|
-
}
|
|
2122
|
+
if (ArrayBuffer.isView(v)) return v.slice?.() ?? v;
|
|
2125
2123
|
if (v instanceof ArrayBuffer) return v.slice(0);
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2124
|
+
const sc = globalThis.structuredClone;
|
|
2125
|
+
if (typeof sc === "function") {
|
|
2126
|
+
try {
|
|
2127
|
+
return sc(v);
|
|
2128
|
+
} catch {
|
|
2129
|
+
}
|
|
2130
2130
|
}
|
|
2131
|
-
return v;
|
|
2131
|
+
if (Array.isArray(v)) return v.map(cloneForSnapshot);
|
|
2132
|
+
const out = {};
|
|
2133
|
+
for (const k of Object.keys(v))
|
|
2134
|
+
out[k] = cloneForSnapshot(v[k]);
|
|
2135
|
+
return out;
|
|
2132
2136
|
};
|
|
2133
2137
|
const deepEqual = (a, b) => {
|
|
2134
2138
|
if (a === b) return true;
|
|
@@ -2152,14 +2156,14 @@ var CrudBase = class {
|
|
|
2152
2156
|
for (let i = 0; i < ua.length; i++) if (ua[i] !== ub[i]) return false;
|
|
2153
2157
|
return true;
|
|
2154
2158
|
}
|
|
2155
|
-
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2156
|
-
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
2157
|
-
if (a.length !== b.length) return false;
|
|
2158
|
-
for (let i = 0; i < a.length; i++)
|
|
2159
|
-
if (!deepEqual(a[i], b[i])) return false;
|
|
2160
|
-
return true;
|
|
2161
|
-
}
|
|
2162
2159
|
if (typeof a === "object" && typeof b === "object") {
|
|
2160
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2161
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
2162
|
+
if (a.length !== b.length) return false;
|
|
2163
|
+
for (let i = 0; i < a.length; i++)
|
|
2164
|
+
if (!deepEqual(a[i], b[i])) return false;
|
|
2165
|
+
return true;
|
|
2166
|
+
}
|
|
2163
2167
|
const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
2164
2168
|
for (const k of keys) {
|
|
2165
2169
|
if (!deepEqual(a[k], b[k])) return false;
|
|
@@ -2181,11 +2185,8 @@ var CrudBase = class {
|
|
|
2181
2185
|
const snapshot = {};
|
|
2182
2186
|
const snapshotHasKey = {};
|
|
2183
2187
|
for (const key of columns) {
|
|
2184
|
-
snapshotHasKey[key] = Object.prototype.hasOwnProperty.call(
|
|
2185
|
-
|
|
2186
|
-
key
|
|
2187
|
-
);
|
|
2188
|
-
snapshot[key] = cloneAtomicOrJson(ent[key]);
|
|
2188
|
+
snapshotHasKey[key] = Object.prototype.hasOwnProperty.call(ent, key);
|
|
2189
|
+
snapshot[key] = cloneForSnapshot(ent[key]);
|
|
2189
2190
|
}
|
|
2190
2191
|
const flush = async () => {
|
|
2191
2192
|
const patch = {};
|
|
@@ -2204,7 +2205,7 @@ var CrudBase = class {
|
|
|
2204
2205
|
if (!deepEqual(before, current)) {
|
|
2205
2206
|
patch[key] = current;
|
|
2206
2207
|
snapshotHasKey[key] = true;
|
|
2207
|
-
snapshot[key] =
|
|
2208
|
+
snapshot[key] = cloneForSnapshot(current);
|
|
2208
2209
|
}
|
|
2209
2210
|
}
|
|
2210
2211
|
if (Object.keys(patch).length) {
|