Skip to content

Commit 0f6d19b

Browse files
fix: update and adjust typescript type definitions
1 parent 3f37e21 commit 0f6d19b

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

index.d.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ type SAHPoolUtil = {
13071307
*
13081308
* This list is the same length as `getFileCount()`.
13091309
*/
1310-
getFilenames: () => string[];
1310+
getFileNames: () => string[];
13111311

13121312
/**
13131313
* Imports the contents of an SQLite database, provided as a byte array or
@@ -1321,12 +1321,31 @@ type SAHPoolUtil = {
13211321
* files, the reason being that this VFS will automatically clean up any
13221322
* non-database files so importing them is pointless.
13231323
*
1324+
* If passed a function for its second argument, its behavior changes to
1325+
* asynchronous, and it imports its data in chunks fed to it by the given
1326+
* callback function. It calls the callback (which may be async) repeatedly,
1327+
* expecting either a Uint8Array or ArrayBuffer (to denote new input) or
1328+
* undefined (to denote EOF).
1329+
*
1330+
* For so long as the callback continues to return non-undefined, it will
1331+
* append incoming data to the given VFS-hosted database file. The result of
1332+
* the resolved Promise when called this way is the size of the resulting
1333+
* database.
1334+
*
1335+
* On success, the number of bytes written is returned. On success this
1336+
* routine rewrites the database header bytes in the output file (not the
1337+
* input array) to force disabling of WAL mode.
1338+
*
13241339
* On a write error, the handle is removed from the pool and made available
13251340
* for re-use.
1326-
*
1327-
* On success, the number of bytes written is returned.
13281341
*/
1329-
importDb: (name: string, data: Uint8Array | ArrayBuffer) => Promise<number>;
1342+
importDb: (
1343+
name: string,
1344+
data:
1345+
| Uint8Array
1346+
| ArrayBuffer
1347+
| (() => Promise<Uint8Array | ArrayBuffer | undefined>),
1348+
) => Promise<number>;
13301349

13311350
/**
13321351
* Removes up to `numEntries` entries from the pool, with the caveat that it
@@ -1390,6 +1409,7 @@ declare class WasmAllocError extends Error {
13901409
/** Exception class used primarily by the oo1 API. */
13911410
declare class SQLite3Error extends Error {
13921411
constructor(message: string);
1412+
resultCode: number;
13931413
}
13941414

13951415
/** A pointer to a location in WASM heap memory. */
@@ -1937,9 +1957,9 @@ declare type Sqlite3Static = {
19371957
name?: string;
19381958
}): Promise<SAHPoolUtil>;
19391959

1940-
WasmAllocError: WasmAllocError;
1960+
WasmAllocError: typeof WasmAllocError;
19411961

1942-
SQLite3Error: SQLite3Error;
1962+
SQLite3Error: typeof SQLite3Error;
19431963

19441964
/**
19451965
* The options with which the API was configured. Whether or not modifying

0 commit comments

Comments
 (0)