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/dist/dexie.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.4, Wed Apr 10 2024
7
+ * Version 4.0.7, Sun May 26 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1144,7 +1144,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1144
1144
  }
1145
1145
  }
1146
1146
 
1147
- var DEXIE_VERSION = '4.0.4';
1147
+ var DEXIE_VERSION = '4.0.7';
1148
1148
  var maxString = String.fromCharCode(65535);
1149
1149
  var minKey = -Infinity;
1150
1150
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -1804,6 +1804,40 @@ var PropModification = (function () {
1804
1804
  }
1805
1805
  PropModification.prototype.execute = function (value) {
1806
1806
  var _a;
1807
+ if (this.add !== undefined) {
1808
+ var term = this.add;
1809
+ if (isArray(term)) {
1810
+ return __spreadArray(__spreadArray([], (isArray(value) ? value : []), true), term, true).sort();
1811
+ }
1812
+ if (typeof term === 'number')
1813
+ return (Number(value) || 0) + term;
1814
+ if (typeof term === 'bigint') {
1815
+ try {
1816
+ return BigInt(value) + term;
1817
+ }
1818
+ catch (_b) {
1819
+ return BigInt(0) + term;
1820
+ }
1821
+ }
1822
+ throw new TypeError("Invalid term ".concat(term));
1823
+ }
1824
+ if (this.remove !== undefined) {
1825
+ var subtrahend_1 = this.remove;
1826
+ if (isArray(subtrahend_1)) {
1827
+ return isArray(value) ? value.filter(function (item) { return !subtrahend_1.includes(item); }).sort() : [];
1828
+ }
1829
+ if (typeof subtrahend_1 === 'number')
1830
+ return Number(value) - subtrahend_1;
1831
+ if (typeof subtrahend_1 === 'bigint') {
1832
+ try {
1833
+ return BigInt(value) - subtrahend_1;
1834
+ }
1835
+ catch (_c) {
1836
+ return BigInt(0) - subtrahend_1;
1837
+ }
1838
+ }
1839
+ throw new TypeError("Invalid subtrahend ".concat(subtrahend_1));
1840
+ }
1807
1841
  var prefixToReplace = (_a = this.replacePrefix) === null || _a === void 0 ? void 0 : _a[0];
1808
1842
  if (prefixToReplace && typeof value === 'string' && value.startsWith(prefixToReplace)) {
1809
1843
  return this.replacePrefix[1] + value.substring(prefixToReplace.length);
@@ -2114,6 +2148,12 @@ var Collection = (function () {
2114
2148
  }
2115
2149
  };
2116
2150
  return _this.clone().primaryKeys().then(function (keys) {
2151
+ var criteria = isPlainKeyRange(ctx) &&
2152
+ ctx.limit === Infinity &&
2153
+ (typeof changes !== 'function' || changes === deleteCallback) && {
2154
+ index: ctx.index,
2155
+ range: ctx.range
2156
+ };
2117
2157
  var nextChunk = function (offset) {
2118
2158
  var count = Math.min(limit, keys.length - offset);
2119
2159
  return coreTable.getMany({
@@ -2146,12 +2186,6 @@ var Collection = (function () {
2146
2186
  }
2147
2187
  }
2148
2188
  }
2149
- var criteria = isPlainKeyRange(ctx) &&
2150
- ctx.limit === Infinity &&
2151
- (typeof changes !== 'function' || changes === deleteCallback) && {
2152
- index: ctx.index,
2153
- range: ctx.range
2154
- };
2155
2189
  return Promise.resolve(addValues.length > 0 &&
2156
2190
  coreTable.mutate({ trans: trans, type: 'add', values: addValues })
2157
2191
  .then(function (res) {
@@ -2167,13 +2201,15 @@ var Collection = (function () {
2167
2201
  values: putValues,
2168
2202
  criteria: criteria,
2169
2203
  changeSpec: typeof changes !== 'function'
2170
- && changes
2204
+ && changes,
2205
+ isAdditionalChunk: offset > 0
2171
2206
  }).then(function (res) { return applyMutateResult(putValues.length, res); }); }).then(function () { return (deleteKeys.length > 0 || (criteria && changes === deleteCallback)) &&
2172
2207
  coreTable.mutate({
2173
2208
  trans: trans,
2174
2209
  type: 'delete',
2175
2210
  keys: deleteKeys,
2176
- criteria: criteria
2211
+ criteria: criteria,
2212
+ isAdditionalChunk: offset > 0
2177
2213
  }).then(function (res) { return applyMutateResult(deleteKeys.length, res); }); }).then(function () {
2178
2214
  return keys.length > offset + count && nextChunk(offset + limit);
2179
2215
  });
@@ -5816,6 +5852,14 @@ if (typeof addEventListener !== 'undefined') {
5816
5852
  });
5817
5853
  }
5818
5854
 
5855
+ function add(value) {
5856
+ return new PropModification({ add: value });
5857
+ }
5858
+
5859
+ function remove(value) {
5860
+ return new PropModification({ remove: value });
5861
+ }
5862
+
5819
5863
  function replacePrefix(a, b) {
5820
5864
  return new PropModification({ replacePrefix: [a, b] });
5821
5865
  }
@@ -5823,5 +5867,5 @@ function replacePrefix(a, b) {
5823
5867
  DexiePromise.rejectionMapper = mapError;
5824
5868
  setDebug(debug);
5825
5869
 
5826
- export { Dexie$1 as Dexie, Entity, PropModSymbol, PropModification, RangeSet, cmp, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap, replacePrefix };
5870
+ export { Dexie$1 as Dexie, Entity, PropModSymbol, PropModification, RangeSet, add, cmp, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap, remove, replacePrefix };
5827
5871
  //# sourceMappingURL=dexie.mjs.map