@minnowdb/core 0.7.0 → 0.7.1

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.
Files changed (95) hide show
  1. package/dist/block-format/block.js +254 -325
  2. package/dist/block-format/checksum.js +30 -52
  3. package/dist/block-format/codecs.js +112 -125
  4. package/dist/block-format/column.js +187 -205
  5. package/dist/block-format/index.js +5 -1
  6. package/dist/block-format/physical.js +371 -387
  7. package/dist/block-format/types.js +4 -1
  8. package/dist/block-format/unicode.js +30 -39
  9. package/dist/date-value.js +67 -78
  10. package/dist/engine/artifact-cache.js +106 -116
  11. package/dist/engine/batch.js +36 -44
  12. package/dist/engine/buffered-writer.js +156 -158
  13. package/dist/engine/byte-estimates.js +20 -22
  14. package/dist/engine/cache-limits.js +24 -25
  15. package/dist/engine/cancellation.js +5 -3
  16. package/dist/engine/catalog.js +64 -73
  17. package/dist/engine/client.js +715 -780
  18. package/dist/engine/database.js +15941 -19313
  19. package/dist/engine/defaults.js +104 -111
  20. package/dist/engine/errors.js +113 -128
  21. package/dist/engine/fts.js +233 -280
  22. package/dist/engine/group-index.js +287 -321
  23. package/dist/engine/index.js +23 -12
  24. package/dist/engine/join-index.js +177 -186
  25. package/dist/engine/keyed-live.js +168 -173
  26. package/dist/engine/live-api.js +0 -1
  27. package/dist/engine/live-equal.js +32 -37
  28. package/dist/engine/live.js +603 -647
  29. package/dist/engine/memory.js +109 -111
  30. package/dist/engine/optimizer.d.ts +19 -1
  31. package/dist/engine/optimizer.js +2633 -2934
  32. package/dist/engine/point-read.js +122 -182
  33. package/dist/engine/query-api.js +12 -3
  34. package/dist/engine/query-cache.js +61 -69
  35. package/dist/engine/query.d.ts +6 -0
  36. package/dist/engine/query.js +8503 -9980
  37. package/dist/engine/result-wire.js +221 -252
  38. package/dist/engine/schema-wire.js +97 -112
  39. package/dist/engine/schema.js +1099 -1254
  40. package/dist/engine/sort-keys.js +315 -389
  41. package/dist/engine/sql-domains.js +646 -769
  42. package/dist/engine/sql-driver.js +0 -1
  43. package/dist/engine/sql-functions.js +1031 -1125
  44. package/dist/engine/sql-json.js +199 -218
  45. package/dist/engine/sql-semantics.js +572 -639
  46. package/dist/engine/typed-live.js +271 -293
  47. package/dist/engine/vector.js +4484 -5145
  48. package/dist/engine/worker-host.d.ts +8 -63
  49. package/dist/engine/worker-host.js +28 -1130
  50. package/dist/engine/worker-indexeddb.d.ts +1 -0
  51. package/dist/engine/worker-indexeddb.js +3 -0
  52. package/dist/engine/worker-memory.d.ts +1 -0
  53. package/dist/engine/worker-memory.js +3 -0
  54. package/dist/engine/worker-opfs.d.ts +1 -0
  55. package/dist/engine/worker-opfs.js +3 -0
  56. package/dist/engine/worker-server.d.ts +93 -0
  57. package/dist/engine/worker-server.js +999 -0
  58. package/dist/engine/worker-store-indexeddb.d.ts +2 -0
  59. package/dist/engine/worker-store-indexeddb.js +11 -0
  60. package/dist/engine/worker-store-memory.d.ts +2 -0
  61. package/dist/engine/worker-store-memory.js +6 -0
  62. package/dist/engine/worker-store-opfs.d.ts +2 -0
  63. package/dist/engine/worker-store-opfs.js +9 -0
  64. package/dist/engine/worker.js +0 -12
  65. package/dist/engine/write-block-planner.js +93 -100
  66. package/dist/plan/index.js +15 -16
  67. package/dist/plan/model.d.ts +6 -0
  68. package/dist/plan/model.js +20 -27
  69. package/dist/storage/index.js +0 -12
  70. package/dist/storage/indexeddb.js +11776 -13171
  71. package/dist/storage/memory.js +1198 -1241
  72. package/dist/storage/opfs/files.js +238 -295
  73. package/dist/storage/opfs/index.js +9 -3
  74. package/dist/storage/opfs/leader.js +4386 -4856
  75. package/dist/storage/opfs/rpc.js +223 -259
  76. package/dist/storage/opfs/snapshot-ledger.js +219 -260
  77. package/dist/storage/opfs/store.js +884 -1003
  78. package/dist/storage/persistence.js +59 -74
  79. package/dist/storage/snapshot-stream.js +788 -826
  80. package/dist/storage/snapshot.js +36 -37
  81. package/dist/storage/toolkit/extents.js +444 -520
  82. package/dist/storage/toolkit/index.js +28 -29
  83. package/dist/storage/toolkit/record-core.js +5792 -6377
  84. package/dist/storage/toolkit/sync-file.js +34 -42
  85. package/dist/storage/toolkit/wal.js +92 -127
  86. package/dist/storage/toolkit/wire.js +232 -256
  87. package/dist/storage/types.js +2948 -3250
  88. package/dist/testing/block-store-conformance.js +1556 -1629
  89. package/dist/testing/index.js +310 -291
  90. package/dist/testing/opfs-shim.js +280 -312
  91. package/dist/testing/simulator.js +496 -534
  92. package/dist/testing/sqllogictest.js +425 -365
  93. package/dist/transactions/index.js +1464 -1712
  94. package/dist/worker-protocol/index.js +70 -69
  95. package/package.json +20 -2
@@ -1,15 +1,26 @@
1
- /**
2
- * The everyday in-thread API. Larger optional surfaces have their own entry points so exporting
3
- * one helper cannot make an application download the worker client or typed live-query layer.
4
- */
5
1
  export * from "./catalog.js";
6
2
  export * from "./database.js";
7
3
  export * from "./errors.js";
8
- export { QueryMemoryBudgetError } from "./memory.js";
9
- export { MAX_SQL_NESTING_DEPTH, MAX_SQL_NUMERIC_DIGITS, MAX_SQL_PARAMETERS, MAX_SQL_PATTERN_CHARACTERS, MAX_SQL_PATTERN_MATCH_STEPS, MAX_SQL_SCALAR_RESULT_CHARACTERS, MAX_SQL_STRUCTURED_VALUE_DEPTH, MAX_SQL_STRUCTURED_VALUE_ITEMS, MAX_SQL_TEXT_CHARACTERS, MAX_SQL_TOKENS, } from "./cache-limits.js";
10
- /**
11
- * The core schema declarations stay on the everyday entry. The optional typed-table renderer is
12
- * available from `@minnowdb/core/schema`, so applications that execute SQL directly do not ship
13
- * its statement builder. Advanced schema internals remain available from that same subpath.
14
- */
15
- export { column, foreignKeyName, isDestructiveStep, planMigration, schema, table, view, } from "./schema.js";
4
+ import { QueryMemoryBudgetError } from "./memory.js";
5
+ import { MAX_SQL_NESTING_DEPTH, MAX_SQL_NUMERIC_DIGITS, MAX_SQL_PARAMETERS, MAX_SQL_PATTERN_CHARACTERS, MAX_SQL_PATTERN_MATCH_STEPS, MAX_SQL_SCALAR_RESULT_CHARACTERS, MAX_SQL_STRUCTURED_VALUE_DEPTH, MAX_SQL_STRUCTURED_VALUE_ITEMS, MAX_SQL_TEXT_CHARACTERS, MAX_SQL_TOKENS } from "./cache-limits.js";
6
+ import { column, foreignKeyName, isDestructiveStep, planMigration, schema, table, view } from "./schema.js";
7
+ export {
8
+ MAX_SQL_NESTING_DEPTH,
9
+ MAX_SQL_NUMERIC_DIGITS,
10
+ MAX_SQL_PARAMETERS,
11
+ MAX_SQL_PATTERN_CHARACTERS,
12
+ MAX_SQL_PATTERN_MATCH_STEPS,
13
+ MAX_SQL_SCALAR_RESULT_CHARACTERS,
14
+ MAX_SQL_STRUCTURED_VALUE_DEPTH,
15
+ MAX_SQL_STRUCTURED_VALUE_ITEMS,
16
+ MAX_SQL_TEXT_CHARACTERS,
17
+ MAX_SQL_TOKENS,
18
+ QueryMemoryBudgetError,
19
+ column,
20
+ foreignKeyName,
21
+ isDestructiveStep,
22
+ planMigration,
23
+ schema,
24
+ table,
25
+ view
26
+ };
@@ -1,203 +1,194 @@
1
1
  import { dateMilliseconds } from "../date-value.js";
2
- import { copyScratchKey, encodeSingleScalarKey, equalsScratch, hashScratch, safeDouble, safeProduct, } from "./group-index.js";
2
+ import { copyScratchKey, encodeSingleScalarKey, equalsScratch, hashScratch, safeDouble, safeProduct } from "./group-index.js";
3
3
  const INITIAL_ENTRY_CAPACITY = 4;
4
4
  const INITIAL_BUCKET_CAPACITY = 8;
5
5
  const INITIAL_KEY_CAPACITY = 32;
6
6
  const ENTRY_FIELDS = 6;
7
7
  const UINT32_BYTES = Uint32Array.BYTES_PER_ELEMENT;
8
- /** Collision-checked scalar-key hash index with typed duplicate row chains. */
9
- export class ByteJoinIndex {
10
- #memory;
11
- #rowNext;
12
- #buckets = new Int32Array(0);
13
- #hashes = new Uint32Array(0);
14
- #offsets = new Uint32Array(0);
15
- #lengths = new Uint32Array(0);
16
- #bucketNext = new Int32Array(0);
17
- #rowHeads = new Int32Array(0);
18
- #rowTails = new Int32Array(0);
19
- #keys = new Uint8Array(0);
20
- #keyLength = 0;
21
- #entryCount = 0;
22
- #unique = true;
23
- #entryReservation;
24
- #bucketReservation;
25
- #keyReservation;
26
- constructor(memory, rowCapacity) {
27
- if (!Number.isSafeInteger(rowCapacity) || rowCapacity < 0) {
28
- throw new RangeError("Join index row capacity must be a non-negative safe integer");
29
- }
30
- this.#memory = memory;
31
- memory.reserve(safeProduct(rowCapacity, Int32Array.BYTES_PER_ELEMENT, "Join duplicate row chains"), "Join duplicate row chains");
32
- this.#rowNext = new Int32Array(rowCapacity);
33
- this.#rowNext.fill(-1);
8
+ class ByteJoinIndex {
9
+ #memory;
10
+ #rowNext;
11
+ #buckets = new Int32Array(0);
12
+ #hashes = new Uint32Array(0);
13
+ #offsets = new Uint32Array(0);
14
+ #lengths = new Uint32Array(0);
15
+ #bucketNext = new Int32Array(0);
16
+ #rowHeads = new Int32Array(0);
17
+ #rowTails = new Int32Array(0);
18
+ #keys = new Uint8Array(0);
19
+ #keyLength = 0;
20
+ #entryCount = 0;
21
+ #unique = true;
22
+ #entryReservation;
23
+ #bucketReservation;
24
+ #keyReservation;
25
+ constructor(memory, rowCapacity) {
26
+ if (!Number.isSafeInteger(rowCapacity) || rowCapacity < 0) {
27
+ throw new RangeError("Join index row capacity must be a non-negative safe integer");
34
28
  }
35
- get unique() {
36
- return this.#unique;
29
+ this.#memory = memory;
30
+ memory.reserve(safeProduct(rowCapacity, Int32Array.BYTES_PER_ELEMENT, "Join duplicate row chains"), "Join duplicate row chains");
31
+ this.#rowNext = new Int32Array(rowCapacity);
32
+ this.#rowNext.fill(-1);
33
+ }
34
+ get unique() {
35
+ return this.#unique;
36
+ }
37
+ add(value, row) {
38
+ if (!Number.isSafeInteger(row) || row < 0 || row >= this.#rowNext.length) {
39
+ throw new RangeError("Join index row is outside its declared capacity");
37
40
  }
38
- add(value, row) {
39
- if (!Number.isSafeInteger(row) || row < 0 || row >= this.#rowNext.length) {
40
- throw new RangeError("Join index row is outside its declared capacity");
41
- }
42
- const length = encodeJoinKey(value);
43
- if (length < 0)
44
- return;
45
- const hash = hashScratch(length);
46
- const existing = this.#find(length, hash);
47
- if (existing >= 0) {
48
- const tail = this.#rowTails[existing] ?? -1;
49
- if (tail < 0)
50
- throw new Error("Join index row chain is corrupt");
51
- this.#rowNext[tail] = row;
52
- this.#rowTails[existing] = row;
53
- this.#unique = false;
54
- return;
55
- }
56
- const encoded = copyScratchKey(length);
57
- const index = this.#entryCount;
58
- this.#ensureEntryCapacity(index + 1);
59
- this.#ensureBucketCapacity(index + 1);
60
- this.#ensureKeyCapacity(encoded.byteLength);
61
- const offset = this.#keyLength;
62
- this.#keys.set(encoded, offset);
63
- this.#keyLength += encoded.byteLength;
64
- this.#hashes[index] = hash;
65
- this.#offsets[index] = offset;
66
- this.#lengths[index] = encoded.byteLength;
67
- this.#rowHeads[index] = row;
68
- this.#rowTails[index] = row;
69
- const bucket = hash & (this.#buckets.length - 1);
70
- this.#bucketNext[index] = this.#buckets[bucket] ?? -1;
71
- this.#buckets[bucket] = index;
72
- this.#entryCount += 1;
41
+ const length = encodeJoinKey(value);
42
+ if (length < 0)
43
+ return;
44
+ const hash = hashScratch(length);
45
+ const existing = this.#find(length, hash);
46
+ if (existing >= 0) {
47
+ const tail = this.#rowTails[existing] ?? -1;
48
+ if (tail < 0)
49
+ throw new Error("Join index row chain is corrupt");
50
+ this.#rowNext[tail] = row;
51
+ this.#rowTails[existing] = row;
52
+ this.#unique = false;
53
+ return;
73
54
  }
74
- firstRow(value) {
75
- const length = encodeJoinKey(value);
76
- if (length < 0)
77
- return -1;
78
- const index = this.#find(length, hashScratch(length));
79
- return index < 0 ? -1 : (this.#rowHeads[index] ?? -1);
55
+ const encoded = copyScratchKey(length);
56
+ const index = this.#entryCount;
57
+ this.#ensureEntryCapacity(index + 1);
58
+ this.#ensureBucketCapacity(index + 1);
59
+ this.#ensureKeyCapacity(encoded.byteLength);
60
+ const offset = this.#keyLength;
61
+ this.#keys.set(encoded, offset);
62
+ this.#keyLength += encoded.byteLength;
63
+ this.#hashes[index] = hash;
64
+ this.#offsets[index] = offset;
65
+ this.#lengths[index] = encoded.byteLength;
66
+ this.#rowHeads[index] = row;
67
+ this.#rowTails[index] = row;
68
+ const bucket = hash & this.#buckets.length - 1;
69
+ this.#bucketNext[index] = this.#buckets[bucket] ?? -1;
70
+ this.#buckets[bucket] = index;
71
+ this.#entryCount += 1;
72
+ }
73
+ firstRow(value) {
74
+ const length = encodeJoinKey(value);
75
+ if (length < 0)
76
+ return -1;
77
+ const index = this.#find(length, hashScratch(length));
78
+ return index < 0 ? -1 : this.#rowHeads[index] ?? -1;
79
+ }
80
+ nextRow(row) {
81
+ return row < 0 || row >= this.#rowNext.length ? -1 : this.#rowNext[row] ?? -1;
82
+ }
83
+ #find(length, hash) {
84
+ if (this.#buckets.length === 0)
85
+ return -1;
86
+ let index = this.#buckets[hash & this.#buckets.length - 1] ?? -1;
87
+ while (index >= 0) {
88
+ if (this.#hashes[index] === hash && this.#lengths[index] === length && equalsScratch(this.#keys, this.#offsets[index] ?? 0, length)) {
89
+ return index;
90
+ }
91
+ index = this.#bucketNext[index] ?? -1;
80
92
  }
81
- nextRow(row) {
82
- return row < 0 || row >= this.#rowNext.length ? -1 : (this.#rowNext[row] ?? -1);
93
+ return -1;
94
+ }
95
+ #ensureEntryCapacity(required) {
96
+ if (required <= this.#hashes.length)
97
+ return;
98
+ let capacity = Math.max(INITIAL_ENTRY_CAPACITY, this.#hashes.length * 2);
99
+ while (capacity < required)
100
+ capacity = safeDouble(capacity, "Join index entries");
101
+ const reservation = this.#memory.reserve(safeProduct(capacity, ENTRY_FIELDS * UINT32_BYTES, "Join index entry storage"), "Join index entry storage");
102
+ try {
103
+ const hashes = new Uint32Array(capacity);
104
+ const offsets = new Uint32Array(capacity);
105
+ const lengths = new Uint32Array(capacity);
106
+ const bucketNext = new Int32Array(capacity);
107
+ const rowHeads = new Int32Array(capacity);
108
+ const rowTails = new Int32Array(capacity);
109
+ bucketNext.fill(-1);
110
+ rowHeads.fill(-1);
111
+ rowTails.fill(-1);
112
+ hashes.set(this.#hashes);
113
+ offsets.set(this.#offsets);
114
+ lengths.set(this.#lengths);
115
+ bucketNext.set(this.#bucketNext);
116
+ rowHeads.set(this.#rowHeads);
117
+ rowTails.set(this.#rowTails);
118
+ this.#hashes = hashes;
119
+ this.#offsets = offsets;
120
+ this.#lengths = lengths;
121
+ this.#bucketNext = bucketNext;
122
+ this.#rowHeads = rowHeads;
123
+ this.#rowTails = rowTails;
124
+ this.#entryReservation?.release();
125
+ this.#entryReservation = reservation;
126
+ } catch (error) {
127
+ reservation.release();
128
+ throw error;
83
129
  }
84
- /** Matches the scratch arena's first `length` bytes against stored keys without copying them. */
85
- #find(length, hash) {
86
- if (this.#buckets.length === 0)
87
- return -1;
88
- let index = this.#buckets[hash & (this.#buckets.length - 1)] ?? -1;
89
- while (index >= 0) {
90
- if (this.#hashes[index] === hash &&
91
- this.#lengths[index] === length &&
92
- equalsScratch(this.#keys, this.#offsets[index] ?? 0, length)) {
93
- return index;
94
- }
95
- index = this.#bucketNext[index] ?? -1;
96
- }
97
- return -1;
130
+ }
131
+ #ensureBucketCapacity(requiredEntries) {
132
+ let capacity = this.#buckets.length;
133
+ if (capacity === 0)
134
+ capacity = INITIAL_BUCKET_CAPACITY;
135
+ while (requiredEntries * 4 > capacity * 3) {
136
+ capacity = safeDouble(capacity, "Join index buckets");
98
137
  }
99
- #ensureEntryCapacity(required) {
100
- if (required <= this.#hashes.length)
101
- return;
102
- let capacity = Math.max(INITIAL_ENTRY_CAPACITY, this.#hashes.length * 2);
103
- while (capacity < required)
104
- capacity = safeDouble(capacity, "Join index entries");
105
- const reservation = this.#memory.reserve(safeProduct(capacity, ENTRY_FIELDS * UINT32_BYTES, "Join index entry storage"), "Join index entry storage");
106
- try {
107
- const hashes = new Uint32Array(capacity);
108
- const offsets = new Uint32Array(capacity);
109
- const lengths = new Uint32Array(capacity);
110
- const bucketNext = new Int32Array(capacity);
111
- const rowHeads = new Int32Array(capacity);
112
- const rowTails = new Int32Array(capacity);
113
- bucketNext.fill(-1);
114
- rowHeads.fill(-1);
115
- rowTails.fill(-1);
116
- hashes.set(this.#hashes);
117
- offsets.set(this.#offsets);
118
- lengths.set(this.#lengths);
119
- bucketNext.set(this.#bucketNext);
120
- rowHeads.set(this.#rowHeads);
121
- rowTails.set(this.#rowTails);
122
- this.#hashes = hashes;
123
- this.#offsets = offsets;
124
- this.#lengths = lengths;
125
- this.#bucketNext = bucketNext;
126
- this.#rowHeads = rowHeads;
127
- this.#rowTails = rowTails;
128
- this.#entryReservation?.release();
129
- this.#entryReservation = reservation;
130
- }
131
- catch (error) {
132
- reservation.release();
133
- throw error;
134
- }
138
+ if (capacity === this.#buckets.length)
139
+ return;
140
+ const reservation = this.#memory.reserve(safeProduct(capacity, Int32Array.BYTES_PER_ELEMENT, "Join index bucket storage"), "Join index bucket storage");
141
+ try {
142
+ const buckets = new Int32Array(capacity);
143
+ buckets.fill(-1);
144
+ for (let index = 0; index < this.#entryCount; index += 1) {
145
+ const bucket = (this.#hashes[index] ?? 0) & capacity - 1;
146
+ this.#bucketNext[index] = buckets[bucket] ?? -1;
147
+ buckets[bucket] = index;
148
+ }
149
+ this.#buckets = buckets;
150
+ this.#bucketReservation?.release();
151
+ this.#bucketReservation = reservation;
152
+ } catch (error) {
153
+ reservation.release();
154
+ throw error;
135
155
  }
136
- #ensureBucketCapacity(requiredEntries) {
137
- let capacity = this.#buckets.length;
138
- if (capacity === 0)
139
- capacity = INITIAL_BUCKET_CAPACITY;
140
- while (requiredEntries * 4 > capacity * 3) {
141
- capacity = safeDouble(capacity, "Join index buckets");
142
- }
143
- if (capacity === this.#buckets.length)
144
- return;
145
- const reservation = this.#memory.reserve(safeProduct(capacity, Int32Array.BYTES_PER_ELEMENT, "Join index bucket storage"), "Join index bucket storage");
146
- try {
147
- const buckets = new Int32Array(capacity);
148
- buckets.fill(-1);
149
- for (let index = 0; index < this.#entryCount; index += 1) {
150
- const bucket = (this.#hashes[index] ?? 0) & (capacity - 1);
151
- this.#bucketNext[index] = buckets[bucket] ?? -1;
152
- buckets[bucket] = index;
153
- }
154
- this.#buckets = buckets;
155
- this.#bucketReservation?.release();
156
- this.#bucketReservation = reservation;
157
- }
158
- catch (error) {
159
- reservation.release();
160
- throw error;
161
- }
162
- }
163
- #ensureKeyCapacity(additionalBytes) {
164
- const required = this.#keyLength + additionalBytes;
165
- if (!Number.isSafeInteger(required))
166
- throw new RangeError("Join key arena is too large");
167
- if (required > 0xffff_ffff)
168
- throw new RangeError("Join key arena exceeds uint32 offsets");
169
- if (required <= this.#keys.byteLength)
170
- return;
171
- let capacity = Math.max(INITIAL_KEY_CAPACITY, this.#keys.byteLength * 2);
172
- while (capacity < required)
173
- capacity = safeDouble(capacity, "Join key arena");
174
- const reservation = this.#memory.reserve(capacity, "Join key arena");
175
- try {
176
- const keys = new Uint8Array(capacity);
177
- keys.set(this.#keys.subarray(0, this.#keyLength));
178
- this.#keys = keys;
179
- this.#keyReservation?.release();
180
- this.#keyReservation = reservation;
181
- }
182
- catch (error) {
183
- reservation.release();
184
- throw error;
185
- }
156
+ }
157
+ #ensureKeyCapacity(additionalBytes) {
158
+ const required = this.#keyLength + additionalBytes;
159
+ if (!Number.isSafeInteger(required))
160
+ throw new RangeError("Join key arena is too large");
161
+ if (required > 4294967295)
162
+ throw new RangeError("Join key arena exceeds uint32 offsets");
163
+ if (required <= this.#keys.byteLength)
164
+ return;
165
+ let capacity = Math.max(INITIAL_KEY_CAPACITY, this.#keys.byteLength * 2);
166
+ while (capacity < required)
167
+ capacity = safeDouble(capacity, "Join key arena");
168
+ const reservation = this.#memory.reserve(capacity, "Join key arena");
169
+ try {
170
+ const keys = new Uint8Array(capacity);
171
+ keys.set(this.#keys.subarray(0, this.#keyLength));
172
+ this.#keys = keys;
173
+ this.#keyReservation?.release();
174
+ this.#keyReservation = reservation;
175
+ } catch (error) {
176
+ reservation.release();
177
+ throw error;
186
178
  }
179
+ }
187
180
  }
188
- /**
189
- * Encodes one join key into the shared scratch arena and returns its byte length, or -1 for keys
190
- * SQL equality can never match (null, undefined, NaN). Dates coerce to their epoch milliseconds,
191
- * so a Date and its number representation join as the same key.
192
- */
193
181
  function encodeJoinKey(value) {
194
- const key = value instanceof Date ? dateMilliseconds(value) : value;
195
- if (key === null || key === undefined)
196
- return -1;
197
- if (typeof key === "number" && Number.isNaN(key))
198
- return -1;
199
- if (typeof key === "boolean" || typeof key === "number" || typeof key === "string") {
200
- return encodeSingleScalarKey(key);
201
- }
202
- throw new TypeError("Join keys must be SQL scalar values");
182
+ const key = value instanceof Date ? dateMilliseconds(value) : value;
183
+ if (key === null || key === void 0)
184
+ return -1;
185
+ if (typeof key === "number" && Number.isNaN(key))
186
+ return -1;
187
+ if (typeof key === "boolean" || typeof key === "number" || typeof key === "string") {
188
+ return encodeSingleScalarKey(key);
189
+ }
190
+ throw new TypeError("Join keys must be SQL scalar values");
203
191
  }
192
+ export {
193
+ ByteJoinIndex
194
+ };