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.mjs
CHANGED
|
@@ -2025,29 +2025,33 @@ var CrudBase = class {
|
|
|
2025
2025
|
if (!await this.repo.exists({ where })) {
|
|
2026
2026
|
throw404();
|
|
2027
2027
|
}
|
|
2028
|
-
const
|
|
2029
|
-
if (!v || typeof v !== "object") return
|
|
2030
|
-
|
|
2031
|
-
|
|
2028
|
+
const isAtomicObject = (v) => {
|
|
2029
|
+
if (!v || typeof v !== "object") return true;
|
|
2030
|
+
if (v instanceof Date) return true;
|
|
2031
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v)) return true;
|
|
2032
|
+
if (ArrayBuffer.isView(v) || v instanceof ArrayBuffer) return true;
|
|
2033
|
+
return false;
|
|
2032
2034
|
};
|
|
2033
|
-
const
|
|
2035
|
+
const cloneForSnapshot = (v) => {
|
|
2034
2036
|
if (v == null) return v;
|
|
2035
2037
|
if (typeof v !== "object") return v;
|
|
2036
2038
|
if (v instanceof Date) return new Date(v.getTime());
|
|
2037
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v))
|
|
2039
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(v))
|
|
2038
2040
|
return Buffer.from(v);
|
|
2039
|
-
|
|
2040
|
-
if (ArrayBuffer.isView(v)) {
|
|
2041
|
-
const ctor = v.constructor;
|
|
2042
|
-
return new ctor(v.slice?.() ?? v);
|
|
2043
|
-
}
|
|
2041
|
+
if (ArrayBuffer.isView(v)) return v.slice?.() ?? v;
|
|
2044
2042
|
if (v instanceof ArrayBuffer) return v.slice(0);
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2043
|
+
const sc = globalThis.structuredClone;
|
|
2044
|
+
if (typeof sc === "function") {
|
|
2045
|
+
try {
|
|
2046
|
+
return sc(v);
|
|
2047
|
+
} catch {
|
|
2048
|
+
}
|
|
2049
2049
|
}
|
|
2050
|
-
return v;
|
|
2050
|
+
if (Array.isArray(v)) return v.map(cloneForSnapshot);
|
|
2051
|
+
const out = {};
|
|
2052
|
+
for (const k of Object.keys(v))
|
|
2053
|
+
out[k] = cloneForSnapshot(v[k]);
|
|
2054
|
+
return out;
|
|
2051
2055
|
};
|
|
2052
2056
|
const deepEqual = (a, b) => {
|
|
2053
2057
|
if (a === b) return true;
|
|
@@ -2071,14 +2075,14 @@ var CrudBase = class {
|
|
|
2071
2075
|
for (let i = 0; i < ua.length; i++) if (ua[i] !== ub[i]) return false;
|
|
2072
2076
|
return true;
|
|
2073
2077
|
}
|
|
2074
|
-
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2075
|
-
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
2076
|
-
if (a.length !== b.length) return false;
|
|
2077
|
-
for (let i = 0; i < a.length; i++)
|
|
2078
|
-
if (!deepEqual(a[i], b[i])) return false;
|
|
2079
|
-
return true;
|
|
2080
|
-
}
|
|
2081
2078
|
if (typeof a === "object" && typeof b === "object") {
|
|
2079
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2080
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
2081
|
+
if (a.length !== b.length) return false;
|
|
2082
|
+
for (let i = 0; i < a.length; i++)
|
|
2083
|
+
if (!deepEqual(a[i], b[i])) return false;
|
|
2084
|
+
return true;
|
|
2085
|
+
}
|
|
2082
2086
|
const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
2083
2087
|
for (const k of keys) {
|
|
2084
2088
|
if (!deepEqual(a[k], b[k])) return false;
|
|
@@ -2100,11 +2104,8 @@ var CrudBase = class {
|
|
|
2100
2104
|
const snapshot = {};
|
|
2101
2105
|
const snapshotHasKey = {};
|
|
2102
2106
|
for (const key of columns) {
|
|
2103
|
-
snapshotHasKey[key] = Object.prototype.hasOwnProperty.call(
|
|
2104
|
-
|
|
2105
|
-
key
|
|
2106
|
-
);
|
|
2107
|
-
snapshot[key] = cloneAtomicOrJson(ent[key]);
|
|
2107
|
+
snapshotHasKey[key] = Object.prototype.hasOwnProperty.call(ent, key);
|
|
2108
|
+
snapshot[key] = cloneForSnapshot(ent[key]);
|
|
2108
2109
|
}
|
|
2109
2110
|
const flush = async () => {
|
|
2110
2111
|
const patch = {};
|
|
@@ -2123,7 +2124,7 @@ var CrudBase = class {
|
|
|
2123
2124
|
if (!deepEqual(before, current)) {
|
|
2124
2125
|
patch[key] = current;
|
|
2125
2126
|
snapshotHasKey[key] = true;
|
|
2126
|
-
snapshot[key] =
|
|
2127
|
+
snapshot[key] = cloneForSnapshot(current);
|
|
2127
2128
|
}
|
|
2128
2129
|
}
|
|
2129
2130
|
if (Object.keys(patch).length) {
|