dexie 4.0.4 → 4.0.7
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 +157 -123
- package/dist/dexie.d.ts +12 -2
- package/dist/dexie.js +56 -10
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +55 -11
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +55 -11
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +5 -2
- package/import-wrapper.mjs +4 -2
- package/package.json +3 -2
package/dist/modern/dexie.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.
|
|
7
|
+
* Version 4.0.7, Sun May 26 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1094,7 +1094,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
-
const DEXIE_VERSION = '4.0.
|
|
1097
|
+
const DEXIE_VERSION = '4.0.7';
|
|
1098
1098
|
const maxString = String.fromCharCode(65535);
|
|
1099
1099
|
const minKey = -Infinity;
|
|
1100
1100
|
const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1720,6 +1720,40 @@ function iterate(cursorPromise, filter, fn, valueMapper) {
|
|
|
1720
1720
|
const PropModSymbol = Symbol();
|
|
1721
1721
|
class PropModification {
|
|
1722
1722
|
execute(value) {
|
|
1723
|
+
if (this.add !== undefined) {
|
|
1724
|
+
const term = this.add;
|
|
1725
|
+
if (isArray(term)) {
|
|
1726
|
+
return [...(isArray(value) ? value : []), ...term].sort();
|
|
1727
|
+
}
|
|
1728
|
+
if (typeof term === 'number')
|
|
1729
|
+
return (Number(value) || 0) + term;
|
|
1730
|
+
if (typeof term === 'bigint') {
|
|
1731
|
+
try {
|
|
1732
|
+
return BigInt(value) + term;
|
|
1733
|
+
}
|
|
1734
|
+
catch {
|
|
1735
|
+
return BigInt(0) + term;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
throw new TypeError(`Invalid term ${term}`);
|
|
1739
|
+
}
|
|
1740
|
+
if (this.remove !== undefined) {
|
|
1741
|
+
const subtrahend = this.remove;
|
|
1742
|
+
if (isArray(subtrahend)) {
|
|
1743
|
+
return isArray(value) ? value.filter(item => !subtrahend.includes(item)).sort() : [];
|
|
1744
|
+
}
|
|
1745
|
+
if (typeof subtrahend === 'number')
|
|
1746
|
+
return Number(value) - subtrahend;
|
|
1747
|
+
if (typeof subtrahend === 'bigint') {
|
|
1748
|
+
try {
|
|
1749
|
+
return BigInt(value) - subtrahend;
|
|
1750
|
+
}
|
|
1751
|
+
catch {
|
|
1752
|
+
return BigInt(0) - subtrahend;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
throw new TypeError(`Invalid subtrahend ${subtrahend}`);
|
|
1756
|
+
}
|
|
1723
1757
|
const prefixToReplace = this.replacePrefix?.[0];
|
|
1724
1758
|
if (prefixToReplace && typeof value === 'string' && value.startsWith(prefixToReplace)) {
|
|
1725
1759
|
return this.replacePrefix[1] + value.substring(prefixToReplace.length);
|
|
@@ -2020,6 +2054,12 @@ class Collection {
|
|
|
2020
2054
|
}
|
|
2021
2055
|
};
|
|
2022
2056
|
return this.clone().primaryKeys().then(keys => {
|
|
2057
|
+
const criteria = isPlainKeyRange(ctx) &&
|
|
2058
|
+
ctx.limit === Infinity &&
|
|
2059
|
+
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2060
|
+
index: ctx.index,
|
|
2061
|
+
range: ctx.range
|
|
2062
|
+
};
|
|
2023
2063
|
const nextChunk = (offset) => {
|
|
2024
2064
|
const count = Math.min(limit, keys.length - offset);
|
|
2025
2065
|
return coreTable.getMany({
|
|
@@ -2052,12 +2092,6 @@ class Collection {
|
|
|
2052
2092
|
}
|
|
2053
2093
|
}
|
|
2054
2094
|
}
|
|
2055
|
-
const criteria = isPlainKeyRange(ctx) &&
|
|
2056
|
-
ctx.limit === Infinity &&
|
|
2057
|
-
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2058
|
-
index: ctx.index,
|
|
2059
|
-
range: ctx.range
|
|
2060
|
-
};
|
|
2061
2095
|
return Promise.resolve(addValues.length > 0 &&
|
|
2062
2096
|
coreTable.mutate({ trans, type: 'add', values: addValues })
|
|
2063
2097
|
.then(res => {
|
|
@@ -2073,13 +2107,15 @@ class Collection {
|
|
|
2073
2107
|
values: putValues,
|
|
2074
2108
|
criteria,
|
|
2075
2109
|
changeSpec: typeof changes !== 'function'
|
|
2076
|
-
&& changes
|
|
2110
|
+
&& changes,
|
|
2111
|
+
isAdditionalChunk: offset > 0
|
|
2077
2112
|
}).then(res => applyMutateResult(putValues.length, res))).then(() => (deleteKeys.length > 0 || (criteria && changes === deleteCallback)) &&
|
|
2078
2113
|
coreTable.mutate({
|
|
2079
2114
|
trans,
|
|
2080
2115
|
type: 'delete',
|
|
2081
2116
|
keys: deleteKeys,
|
|
2082
|
-
criteria
|
|
2117
|
+
criteria,
|
|
2118
|
+
isAdditionalChunk: offset > 0
|
|
2083
2119
|
}).then(res => applyMutateResult(deleteKeys.length, res))).then(() => {
|
|
2084
2120
|
return keys.length > offset + count && nextChunk(offset + limit);
|
|
2085
2121
|
});
|
|
@@ -5713,6 +5749,14 @@ if (typeof addEventListener !== 'undefined') {
|
|
|
5713
5749
|
});
|
|
5714
5750
|
}
|
|
5715
5751
|
|
|
5752
|
+
function add(value) {
|
|
5753
|
+
return new PropModification({ add: value });
|
|
5754
|
+
}
|
|
5755
|
+
|
|
5756
|
+
function remove(value) {
|
|
5757
|
+
return new PropModification({ remove: value });
|
|
5758
|
+
}
|
|
5759
|
+
|
|
5716
5760
|
function replacePrefix(a, b) {
|
|
5717
5761
|
return new PropModification({ replacePrefix: [a, b] });
|
|
5718
5762
|
}
|
|
@@ -5720,5 +5764,5 @@ function replacePrefix(a, b) {
|
|
|
5720
5764
|
DexiePromise.rejectionMapper = mapError;
|
|
5721
5765
|
setDebug(debug);
|
|
5722
5766
|
|
|
5723
|
-
export { Dexie$1 as Dexie, Entity, PropModSymbol, PropModification, RangeSet, cmp, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap, replacePrefix };
|
|
5767
|
+
export { Dexie$1 as Dexie, Entity, PropModSymbol, PropModification, RangeSet, add, cmp, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap, remove, replacePrefix };
|
|
5724
5768
|
//# sourceMappingURL=dexie.mjs.map
|