fake-indexeddb 6.2.7 → 6.2.8

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 CHANGED
@@ -204,7 +204,7 @@ import "fake-indexeddb/auto";
204
204
 
205
205
  ## Quality
206
206
 
207
- Here's a comparison of fake-indexeddb and real browser IndexedDB implementations on [the Web Platform Tests IndexedDB suite](https://wpt.fyi/results/IndexedDB) as of <!-- last_updated_date_start -->October 29, 2026<!-- last_updated_date_end -->:
207
+ Here's a comparison of fake-indexeddb and real browser IndexedDB implementations on [the Web Platform Tests IndexedDB suite](https://wpt.fyi/results/IndexedDB) as of <!-- last_updated_date_start -->November 8, 2026<!-- last_updated_date_end -->:
208
208
 
209
209
  <!-- DO NOT MANUALLY OVERWRITE THE TABLE BELOW! -->
210
210
  <!-- To update the results, run `pnpm run update-wpt-results` -->
@@ -212,11 +212,11 @@ Here's a comparison of fake-indexeddb and real browser IndexedDB implementations
212
212
  <!-- wpt_results_total=1678 -->
213
213
  | Implementation | Version | Passed | % |
214
214
  | --- | --- | --- | --- |
215
- | Chrome | 159.0.8130.0 | 1672 | 99.6% |
216
- | Firefox | 161.0a1 | 1671 | 99.6% |
217
- | Safari | 255 preview | 1676 | 99.9% |
218
- | Ladybird | 1.0-28077c350dc | 1668 | 99.4% |
219
- | fake-indexeddb | 6.2.7 | 1369 | 81.6% |
215
+ | Chrome | 159.0.8149.0 | 1672 | 99.6% |
216
+ | Firefox | 160.0b5 | 1671 | 99.6% |
217
+ | Safari | 256 preview | 1677 | 99.9% |
218
+ | Ladybird | 1.0-d48145ebfce | 1668 | 99.4% |
219
+ | fake-indexeddb | 6.2.8 | 1369 | 81.6% |
220
220
  <!-- wpt_results_end -->
221
221
 
222
222
  Keep in mind that these tests include a lot of edge cases (such as rare error conditions), so even hitting ~40% likely means that the core IndexedDB functionality is covered. Your app will probably work fine.
@@ -271,9 +271,12 @@ class FDBTransaction extends _FakeEventTarget.default {
271
271
  const idx = transactions.indexOf(this);
272
272
  if (idx !== -1) {
273
273
  transactions.splice(idx, 1);
274
- } else {
275
- throw new Error("should have been able to remove transaction");
276
274
  }
275
+ // Note: it's possible to hit this twice in the same aborted transaction
276
+ // due to an abort inside an `onerror` (issue #173). In that case we hit:
277
+ // 1. once due to the user's `abort()`
278
+ // 2. once again due to the `if (!event.canceled)` above
279
+ // So we can just ignore the fact that the transaction was already removed
277
280
  });
278
281
  }
279
282
  commit() {
@@ -99,11 +99,13 @@ class Index {
99
99
  }
100
100
  if (!this.multiEntry || !Array.isArray(indexKey)) {
101
101
  try {
102
- (0, _valueToKey.default)(indexKey);
102
+ // "Convert a value to a key": a single key path returns the
103
+ // value as-is (e.g. a typed array), so store the converted
104
+ // key, not the raw value.
105
+ return (0, _valueToKey.default)(indexKey);
103
106
  } catch (e) {
104
107
  return;
105
108
  }
106
- return indexKey;
107
109
  }
108
110
 
109
111
  // remove any elements from index key that are not valid keys and remove any duplicate elements from index
@@ -8,6 +8,7 @@ var _FDBRecord = _interopRequireDefault(require("../FDBRecord.js"));
8
8
  var _errors = require("./errors.js");
9
9
  var _extractKey = _interopRequireDefault(require("./extractKey.js"));
10
10
  var _KeyGenerator = _interopRequireDefault(require("./KeyGenerator.js"));
11
+ var _valueToKey = _interopRequireDefault(require("./valueToKey.js"));
11
12
  var _RecordStore = _interopRequireDefault(require("./RecordStore.js"));
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-object-store
@@ -86,7 +87,11 @@ class ObjectStore {
86
87
  if (this.keyPath !== null) {
87
88
  const key = (0, _extractKey.default)(this.keyPath, newRecord.value).key;
88
89
  if (key !== undefined) {
89
- newRecord.key = key;
90
+ // "Convert a value to a key": a single key path returns the
91
+ // value as-is (e.g. a typed array), so convert it here. For
92
+ // an array key path, extractKey already converted each part
93
+ // and valueToKey is idempotent on converted keys.
94
+ newRecord.key = (0, _valueToKey.default)(key);
90
95
  }
91
96
  }
92
97
  const rollbackLogForThisOperation = [];
@@ -264,9 +264,12 @@ class FDBTransaction extends FakeEventTarget {
264
264
  const idx = transactions.indexOf(this);
265
265
  if (idx !== -1) {
266
266
  transactions.splice(idx, 1);
267
- } else {
268
- throw new Error("should have been able to remove transaction");
269
267
  }
268
+ // Note: it's possible to hit this twice in the same aborted transaction
269
+ // due to an abort inside an `onerror` (issue #173). In that case we hit:
270
+ // 1. once due to the user's `abort()`
271
+ // 2. once again due to the `if (!event.canceled)` above
272
+ // So we can just ignore the fact that the transaction was already removed
270
273
  });
271
274
  }
272
275
  commit() {
@@ -92,11 +92,13 @@ class Index {
92
92
  }
93
93
  if (!this.multiEntry || !Array.isArray(indexKey)) {
94
94
  try {
95
- valueToKey(indexKey);
95
+ // "Convert a value to a key": a single key path returns the
96
+ // value as-is (e.g. a typed array), so store the converted
97
+ // key, not the raw value.
98
+ return valueToKey(indexKey);
96
99
  } catch (e) {
97
100
  return;
98
101
  }
99
- return indexKey;
100
102
  }
101
103
 
102
104
  // remove any elements from index key that are not valid keys and remove any duplicate elements from index
@@ -2,6 +2,7 @@ import FDBRecord from "../FDBRecord.js";
2
2
  import { DataError } from "./errors.js";
3
3
  import extractKey from "./extractKey.js";
4
4
  import KeyGenerator from "./KeyGenerator.js";
5
+ import valueToKey from "./valueToKey.js";
5
6
  import RecordStore from "./RecordStore.js";
6
7
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-object-store
7
8
  class ObjectStore {
@@ -79,7 +80,11 @@ class ObjectStore {
79
80
  if (this.keyPath !== null) {
80
81
  const key = extractKey(this.keyPath, newRecord.value).key;
81
82
  if (key !== undefined) {
82
- newRecord.key = key;
83
+ // "Convert a value to a key": a single key path returns the
84
+ // value as-is (e.g. a typed array), so convert it here. For
85
+ // an array key path, extractKey already converted each part
86
+ // and valueToKey is idempotent on converted keys.
87
+ newRecord.key = valueToKey(key);
83
88
  }
84
89
  }
85
90
  const rollbackLogForThisOperation = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fake-indexeddb",
3
- "version": "6.2.7",
3
+ "version": "6.2.8",
4
4
  "description": "Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API",
5
5
  "homepage": "https://github.com/dumbmatter/fakeIndexedDB",
6
6
  "repository": {