sedentary 0.0.50 → 0.0.51
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/cjs/db.js +15 -5
- package/dist/cjs/index.js +3 -2
- package/dist/es/db.js +12 -3
- package/dist/es/index.js +1 -1
- package/dist/types/db.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/db.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.deepDiff = exports.deepCopy = exports.Transaction = exports.DB = exports.Table = exports.Attribute = exports.Type = exports.EntryBase = exports.transaction = exports.size = exports.loaded = exports.base = exports.actions = void 0;
|
|
4
4
|
exports.actions = Symbol("actions");
|
|
5
5
|
exports.base = Symbol("base");
|
|
6
6
|
exports.loaded = Symbol("loaded");
|
|
@@ -137,7 +137,17 @@ class Transaction {
|
|
|
137
137
|
}
|
|
138
138
|
exports.Transaction = Transaction;
|
|
139
139
|
const sortedEntries = (obj) => Object.entries(obj).sort((entryA, entryB) => (entryA[0] > entryB[0] ? -1 : 1));
|
|
140
|
-
function
|
|
140
|
+
function deepCopy(o) {
|
|
141
|
+
if (!o || typeof o !== "object")
|
|
142
|
+
return o;
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
+
const [ret, entries] = o instanceof Array ? [new Array(o.length), o.entries()] : [{}, Object.entries(o)];
|
|
145
|
+
for (const [k, v] of entries)
|
|
146
|
+
ret[k] = deepCopy(v);
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
exports.deepCopy = deepCopy;
|
|
150
|
+
function deepDiff(a, b) {
|
|
141
151
|
if (typeof a !== "object")
|
|
142
152
|
return a !== b;
|
|
143
153
|
if (typeof b !== "object")
|
|
@@ -150,7 +160,7 @@ function differ(a, b) {
|
|
|
150
160
|
if (!(b instanceof Array))
|
|
151
161
|
return true;
|
|
152
162
|
for (const [i, value] of a.entries())
|
|
153
|
-
if (
|
|
163
|
+
if (deepDiff(value, b[i]))
|
|
154
164
|
return true;
|
|
155
165
|
return false;
|
|
156
166
|
}
|
|
@@ -159,8 +169,8 @@ function differ(a, b) {
|
|
|
159
169
|
if (entriesA.length !== entriesB.length)
|
|
160
170
|
return true;
|
|
161
171
|
for (const [i, [key, value]] of entriesA.entries())
|
|
162
|
-
if (key !== entriesB[i][0] ||
|
|
172
|
+
if (key !== entriesB[i][0] || deepDiff(value, entriesB[i][1]))
|
|
163
173
|
return true;
|
|
164
174
|
return false;
|
|
165
175
|
}
|
|
166
|
-
exports.
|
|
176
|
+
exports.deepDiff = deepDiff;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Sedentary = exports.Type = exports.transaction = exports.Transaction = exports.Table = exports.size = exports.loaded = exports.EntryBase = exports.
|
|
3
|
+
exports.Sedentary = exports.Type = exports.transaction = exports.Transaction = exports.Table = exports.size = exports.loaded = exports.EntryBase = exports.deepDiff = exports.deepCopy = exports.DB = exports.base = exports.Attribute = void 0;
|
|
4
4
|
const db_1 = require("./db");
|
|
5
5
|
var db_2 = require("./db");
|
|
6
6
|
Object.defineProperty(exports, "Attribute", { enumerable: true, get: function () { return db_2.Attribute; } });
|
|
7
7
|
Object.defineProperty(exports, "base", { enumerable: true, get: function () { return db_2.base; } });
|
|
8
8
|
Object.defineProperty(exports, "DB", { enumerable: true, get: function () { return db_2.DB; } });
|
|
9
|
-
Object.defineProperty(exports, "
|
|
9
|
+
Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return db_2.deepCopy; } });
|
|
10
|
+
Object.defineProperty(exports, "deepDiff", { enumerable: true, get: function () { return db_2.deepDiff; } });
|
|
10
11
|
Object.defineProperty(exports, "EntryBase", { enumerable: true, get: function () { return db_2.EntryBase; } });
|
|
11
12
|
Object.defineProperty(exports, "loaded", { enumerable: true, get: function () { return db_2.loaded; } });
|
|
12
13
|
Object.defineProperty(exports, "size", { enumerable: true, get: function () { return db_2.size; } });
|
package/dist/es/db.js
CHANGED
|
@@ -132,7 +132,16 @@ export class Transaction {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
const sortedEntries = (obj) => Object.entries(obj).sort((entryA, entryB) => (entryA[0] > entryB[0] ? -1 : 1));
|
|
135
|
-
export function
|
|
135
|
+
export function deepCopy(o) {
|
|
136
|
+
if (!o || typeof o !== "object")
|
|
137
|
+
return o;
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
const [ret, entries] = o instanceof Array ? [new Array(o.length), o.entries()] : [{}, Object.entries(o)];
|
|
140
|
+
for (const [k, v] of entries)
|
|
141
|
+
ret[k] = deepCopy(v);
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
export function deepDiff(a, b) {
|
|
136
145
|
if (typeof a !== "object")
|
|
137
146
|
return a !== b;
|
|
138
147
|
if (typeof b !== "object")
|
|
@@ -145,7 +154,7 @@ export function differ(a, b) {
|
|
|
145
154
|
if (!(b instanceof Array))
|
|
146
155
|
return true;
|
|
147
156
|
for (const [i, value] of a.entries())
|
|
148
|
-
if (
|
|
157
|
+
if (deepDiff(value, b[i]))
|
|
149
158
|
return true;
|
|
150
159
|
return false;
|
|
151
160
|
}
|
|
@@ -154,7 +163,7 @@ export function differ(a, b) {
|
|
|
154
163
|
if (entriesA.length !== entriesB.length)
|
|
155
164
|
return true;
|
|
156
165
|
for (const [i, [key, value]] of entriesA.entries())
|
|
157
|
-
if (key !== entriesB[i][0] ||
|
|
166
|
+
if (key !== entriesB[i][0] || deepDiff(value, entriesB[i][1]))
|
|
158
167
|
return true;
|
|
159
168
|
return false;
|
|
160
169
|
}
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { actions, Attribute, base, EntryBase, loaded, size, Table, Transaction, transaction, Type } from "./db";
|
|
2
|
-
export { Attribute, base, DB,
|
|
2
|
+
export { Attribute, base, DB, deepCopy, deepDiff, EntryBase, loaded, size, Table, Transaction, transaction, Type } from "./db";
|
|
3
3
|
const attributes = Symbol("attributes");
|
|
4
4
|
const methods = Symbol("methods");
|
|
5
5
|
const operators = ["=", ">", "<", ">=", "<=", "<>", "IN", "IS NULL", "LIKE", "NOT"];
|
package/dist/types/db.d.ts
CHANGED
|
@@ -120,5 +120,6 @@ export declare class Transaction {
|
|
|
120
120
|
protected preCommit(): void;
|
|
121
121
|
rollback(): Promise<void>;
|
|
122
122
|
}
|
|
123
|
-
export declare function
|
|
123
|
+
export declare function deepCopy(o: unknown): any;
|
|
124
|
+
export declare function deepDiff(a: unknown, b: unknown): boolean;
|
|
124
125
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, DB, EntryBase, ForeignKeyOptions, Transaction, Type } from "./db";
|
|
2
|
-
export { Action, Attribute, base, DB,
|
|
2
|
+
export { Action, Attribute, base, DB, deepCopy, deepDiff, EntryBase, ForeignKeyActions, ForeignKeyOptions, Index, loaded, size, Table, Transaction, transaction, Type } from "./db";
|
|
3
3
|
export declare type TypeDefinition<T, E> = (() => Type<T, E>) | Type<T, E>;
|
|
4
4
|
export interface AttributeOptions<T, E> {
|
|
5
5
|
defaultValue?: T;
|
package/package.json
CHANGED