@livestore/wa-sqlite 1.0.1-dev.20 → 1.0.1-dev.22
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/package.json +1 -1
- package/src/sqlite-api.js +9 -3
package/package.json
CHANGED
package/src/sqlite-api.js
CHANGED
|
@@ -260,10 +260,16 @@ export function Factory(Module) {
|
|
|
260
260
|
let address = f(db, schema, piSize, 0);
|
|
261
261
|
if (address === 0) {
|
|
262
262
|
address = f(db, schema, piSize, SQLITE_SERIALIZE_NOCOPY);
|
|
263
|
+
const size = Module.getValue(piSize, '*');
|
|
264
|
+
const result = Module.HEAPU8.subarray(address, address + size);
|
|
265
|
+
// NOTE Given that the memory is owned by SQLite, we must copy it.
|
|
266
|
+
return new Uint8Array(result.slice());
|
|
267
|
+
} else {
|
|
268
|
+
const size = Module.getValue(piSize, '*');
|
|
269
|
+
const result = Module.HEAPU8.subarray(address, address + size);
|
|
270
|
+
// Here we're getting a copy of the memory, so we can return it directly.
|
|
271
|
+
return new Uint8Array(result);
|
|
263
272
|
}
|
|
264
|
-
const size = Module.getValue(piSize, '*');
|
|
265
|
-
const result = Module.HEAPU8.subarray(address, address + size);
|
|
266
|
-
return result;
|
|
267
273
|
};
|
|
268
274
|
})();
|
|
269
275
|
|