sedentary 0.0.46 → 0.0.47
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 +29 -1
- package/dist/cjs/index.js +2 -1
- package/dist/es/db.js +27 -0
- package/dist/es/index.js +1 -1
- package/dist/types/db.d.ts +1 -0
- 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.Transaction = exports.DB = exports.Table = exports.Attribute = exports.Type = exports.EntryBase = exports.loaded = exports.actions = void 0;
|
|
3
|
+
exports.differ = exports.Transaction = exports.DB = exports.Table = exports.Attribute = exports.Type = exports.EntryBase = exports.loaded = exports.actions = void 0;
|
|
4
4
|
exports.actions = Symbol("actions");
|
|
5
5
|
exports.loaded = Symbol("loaded");
|
|
6
6
|
class EntryBase {
|
|
@@ -133,3 +133,31 @@ class Transaction {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
exports.Transaction = Transaction;
|
|
136
|
+
const sortedEntries = (obj) => Object.entries(obj).sort((entryA, entryB) => (entryA[0] > entryB[0] ? -1 : 1));
|
|
137
|
+
function differ(a, b) {
|
|
138
|
+
if (typeof a !== "object")
|
|
139
|
+
return a !== b;
|
|
140
|
+
if (typeof b !== "object")
|
|
141
|
+
return true;
|
|
142
|
+
if (a === null)
|
|
143
|
+
return b !== null;
|
|
144
|
+
if (b === null)
|
|
145
|
+
return true;
|
|
146
|
+
if (a instanceof Array) {
|
|
147
|
+
if (!(b instanceof Array))
|
|
148
|
+
return true;
|
|
149
|
+
for (const [i, value] of a.entries())
|
|
150
|
+
if (differ(value, b[i]))
|
|
151
|
+
return true;
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const entriesA = sortedEntries(a);
|
|
155
|
+
const entriesB = sortedEntries(b);
|
|
156
|
+
if (entriesA.length !== entriesB.length)
|
|
157
|
+
return true;
|
|
158
|
+
for (const [i, [key, value]] of entriesA.entries())
|
|
159
|
+
if (key !== entriesB[i][0] || differ(value, entriesB[i][1]))
|
|
160
|
+
return true;
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
exports.differ = differ;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Sedentary = exports.Type = exports.Transaction = exports.Table = exports.EntryBase = exports.DB = exports.Attribute = void 0;
|
|
3
|
+
exports.Sedentary = exports.Type = exports.Transaction = exports.Table = exports.EntryBase = exports.differ = exports.DB = 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, "DB", { enumerable: true, get: function () { return db_2.DB; } });
|
|
8
|
+
Object.defineProperty(exports, "differ", { enumerable: true, get: function () { return db_2.differ; } });
|
|
8
9
|
Object.defineProperty(exports, "EntryBase", { enumerable: true, get: function () { return db_2.EntryBase; } });
|
|
9
10
|
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return db_2.Table; } });
|
|
10
11
|
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return db_2.Transaction; } });
|
package/dist/es/db.js
CHANGED
|
@@ -128,3 +128,30 @@ export class Transaction {
|
|
|
128
128
|
this.clean();
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
const sortedEntries = (obj) => Object.entries(obj).sort((entryA, entryB) => (entryA[0] > entryB[0] ? -1 : 1));
|
|
132
|
+
export function differ(a, b) {
|
|
133
|
+
if (typeof a !== "object")
|
|
134
|
+
return a !== b;
|
|
135
|
+
if (typeof b !== "object")
|
|
136
|
+
return true;
|
|
137
|
+
if (a === null)
|
|
138
|
+
return b !== null;
|
|
139
|
+
if (b === null)
|
|
140
|
+
return true;
|
|
141
|
+
if (a instanceof Array) {
|
|
142
|
+
if (!(b instanceof Array))
|
|
143
|
+
return true;
|
|
144
|
+
for (const [i, value] of a.entries())
|
|
145
|
+
if (differ(value, b[i]))
|
|
146
|
+
return true;
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
const entriesA = sortedEntries(a);
|
|
150
|
+
const entriesB = sortedEntries(b);
|
|
151
|
+
if (entriesA.length !== entriesB.length)
|
|
152
|
+
return true;
|
|
153
|
+
for (const [i, [key, value]] of entriesA.entries())
|
|
154
|
+
if (key !== entriesB[i][0] || differ(value, entriesB[i][1]))
|
|
155
|
+
return true;
|
|
156
|
+
return false;
|
|
157
|
+
}
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { actions, Attribute, EntryBase, Table, Transaction, Type } from "./db";
|
|
2
|
-
export { Attribute, DB, EntryBase, Table, Transaction, Type } from "./db";
|
|
2
|
+
export { Attribute, DB, differ, EntryBase, Table, Transaction, Type } from "./db";
|
|
3
3
|
const operators = ["=", ">", "<", ">=", "<=", "<>", "IN", "IS NULL", "LIKE", "NOT"];
|
|
4
4
|
const allowedOption = ["indexes", "int8id", "parent", "primaryKey", "sync", "tableName"];
|
|
5
5
|
const reservedNames = [
|
package/dist/types/db.d.ts
CHANGED
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, DB, EntryBase, ForeignKeyActions, ForeignKeyOptions, Index, Table, Transaction, Type } from "./db";
|
|
2
|
+
export { Action, Attribute, DB, differ, EntryBase, ForeignKeyActions, ForeignKeyOptions, Index, Table, 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