@sqlite.org/sqlite-wasm
Advanced tools
Comparing version 3.45.3-build2 to 3.45.3-build3
{ | ||
"name": "@sqlite.org/sqlite-wasm", | ||
"version": "3.45.3-build2", | ||
"version": "3.45.3-build3", | ||
"description": "SQLite Wasm conveniently wrapped as an ES Module.", | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
"prettier": "^3.2.5", | ||
"publint": "^0.2.7", | ||
"publint": "^0.2.8", | ||
"prettier-plugin-jsdoc": "^1.3.0", | ||
@@ -64,0 +64,0 @@ "shx": "^0.3.4" |
@@ -5,3 +5,3 @@ # SQLite Wasm | ||
> **Warning** | ||
> [!Warning] | ||
> | ||
@@ -36,3 +36,3 @@ > This project wraps the code of | ||
> **Warning** | ||
> [!Warning] | ||
> | ||
@@ -48,6 +48,6 @@ > For this to work, you need to set the following headers on your server: | ||
const log = (...args) => console.log(...args); | ||
const error = (...args) => console.error(...args); | ||
const log = console.log; | ||
const error = console.error; | ||
(async () => { | ||
const initializeSQLite = async () => { | ||
try { | ||
@@ -58,5 +58,3 @@ log('Loading and initializing SQLite3 module...'); | ||
const _promiser = sqlite3Worker1Promiser({ | ||
onready: () => { | ||
resolve(_promiser); | ||
}, | ||
onready: () => resolve(_promiser), | ||
}); | ||
@@ -67,14 +65,12 @@ }); | ||
let response; | ||
const configResponse = await promiser('config-get', {}); | ||
log('Running SQLite3 version', configResponse.result.version.libVersion); | ||
response = await promiser('config-get', {}); | ||
log('Running SQLite3 version', response.result.version.libVersion); | ||
response = await promiser('open', { | ||
const openResponse = await promiser('open', { | ||
filename: 'file:mydb.sqlite3?vfs=opfs', | ||
}); | ||
const { dbId } = response; | ||
const { dbId } = openResponse; | ||
log( | ||
'OPFS is available, created persisted database at', | ||
response.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'), | ||
openResponse.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'), | ||
); | ||
@@ -88,3 +84,5 @@ // Your SQLite code here. | ||
} | ||
})(); | ||
}; | ||
initializeSQLite(); | ||
``` | ||
@@ -97,3 +95,3 @@ | ||
> **Warning** | ||
> [!Warning] | ||
> | ||
@@ -115,30 +113,31 @@ > For this to work, you need to set the following headers on your server: | ||
const log = (...args) => console.log(...args); | ||
const error = (...args) => console.error(...args); | ||
const log = console.log; | ||
const error = console.error; | ||
const start = function (sqlite3) { | ||
const start = (sqlite3) => { | ||
log('Running SQLite3 version', sqlite3.version.libVersion); | ||
let db; | ||
if ('opfs' in sqlite3) { | ||
db = new sqlite3.oo1.OpfsDb('/mydb.sqlite3'); | ||
log('OPFS is available, created persisted database at', db.filename); | ||
} else { | ||
db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct'); | ||
log('OPFS is not available, created transient database', db.filename); | ||
} | ||
const db = | ||
'opfs' in sqlite3 | ||
? new sqlite3.oo1.OpfsDb('/mydb.sqlite3') | ||
: new sqlite3.oo1.DB('/mydb.sqlite3', 'ct'); | ||
log( | ||
'opfs' in sqlite3 | ||
? `OPFS is available, created persisted database at ${db.filename}` | ||
: `OPFS is not available, created transient database ${db.filename}`, | ||
); | ||
// Your SQLite code here. | ||
}; | ||
log('Loading and initializing SQLite3 module...'); | ||
sqlite3InitModule({ | ||
print: log, | ||
printErr: error, | ||
}).then((sqlite3) => { | ||
log('Done initializing. Running demo...'); | ||
const initializeSQLite = async () => { | ||
try { | ||
log('Loading and initializing SQLite3 module...'); | ||
const sqlite3 = await sqlite3InitModule({ print: log, printErr: error }); | ||
log('Done initializing. Running demo...'); | ||
start(sqlite3); | ||
} catch (err) { | ||
error(err.name, err.message); | ||
error('Initialization error:', err.name, err.message); | ||
} | ||
}); | ||
}; | ||
initializeSQLite(); | ||
``` | ||
@@ -154,6 +153,6 @@ | ||
const log = (...args) => console.log(...args); | ||
const error = (...args) => console.error(...args); | ||
const log = console.log; | ||
const error = console.error; | ||
const start = function (sqlite3) { | ||
const start = (sqlite3) => { | ||
log('Running SQLite3 version', sqlite3.version.libVersion); | ||
@@ -164,14 +163,17 @@ const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct'); | ||
log('Loading and initializing SQLite3 module...'); | ||
sqlite3InitModule({ | ||
print: log, | ||
printErr: error, | ||
}).then((sqlite3) => { | ||
const initializeSQLite = async () => { | ||
try { | ||
log('Loading and initializing SQLite3 module...'); | ||
const sqlite3 = await sqlite3InitModule({ | ||
print: log, | ||
printErr: error, | ||
}); | ||
log('Done initializing. Running demo...'); | ||
start(sqlite3); | ||
} catch (err) { | ||
error(err.name, err.message); | ||
error('Initialization error:', err.name, err.message); | ||
} | ||
}); | ||
}; | ||
initializeSQLite(); | ||
``` | ||
@@ -178,0 +180,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3129880
60370
235