Skip to content

Commit 654f8df

Browse files
committed
Add jsdoc documentation for initSqlJs
1 parent fa49dae commit 654f8df

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/api.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
stackSave
1717
*/
1818

19+
/**
20+
* @typedef {{Database:Database}} SqlJs
21+
* @property {Database} Database the database constructor
22+
*/
23+
24+
/**
25+
* @typedef {{locateFile:function(string):string}} SqlJsConfig
26+
* @property {function(string):string} locateFile
27+
* a function that returns the full path to a resource given its file name
28+
* @see https://emscripten.org/docs/api_reference/module.html
29+
*/
30+
31+
/**
32+
* Asynchronously initializes sql.js
33+
* @function initSqlJs
34+
* @param {SqlJsConfig} config module inititialization parameters
35+
* @returns {SqlJs}
36+
* @example
37+
* initSqlJs({
38+
* locateFile: name => '/path/to/assets/' + name
39+
* }).then(SQL => {
40+
* const db = new SQL.Database();
41+
* const result = db.exec("select 'hello world'");
42+
* console.log(result);
43+
* })
44+
*/
1945

2046
/**
2147
* @module SqlJs

0 commit comments

Comments
 (0)