diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90045b0..597f7ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,10 +19,10 @@ jobs: deno-version: "v2.x" - name: Check Formatting - run: deno fmt --check --ignore=sqlite + run: deno fmt --check - name: Lint - run: deno lint --ignore=sqlite,bench + run: deno lint - name: Check run: deno check src/ test/ scripts/ mod.ts diff --git a/bench/bench_bun.js b/bench/bench_bun.js index 96e1f16..a1866bb 100644 --- a/bench/bench_bun.js +++ b/bench/bench_bun.js @@ -1,3 +1,4 @@ +import process from "node:process"; import { Database } from "bun:sqlite"; // Unsafe concurrency is default. diff --git a/bench/bench_bun_ffi.js b/bench/bench_bun_ffi.js index 376c99e..d3a061c 100644 --- a/bench/bench_bun_ffi.js +++ b/bench/bench_bun_ffi.js @@ -1,3 +1,4 @@ +import process from "node:process"; import { dlopen, ptr } from "bun:ffi"; import { diff --git a/bench/bench_deno_wasm.js b/bench/bench_deno_wasm.js index 3bed502..ea35d38 100644 --- a/bench/bench_deno_wasm.js +++ b/bench/bench_deno_wasm.js @@ -1,4 +1,4 @@ -import { DB } from "https://deno.land/x/sqlite/mod.ts"; +import { DB } from "https://deno.land/x/sqlite@v3.9.1/mod.ts"; import { nextTick } from "https://deno.land/std@0.126.0/node/_next_tick.ts"; const db = new DB(":memory:"); diff --git a/bench/bench_node.js b/bench/bench_node.js index 13d9785..b3931b1 100644 --- a/bench/bench_node.js +++ b/bench/bench_node.js @@ -1,3 +1,4 @@ +import process from "node:process"; const db = require("better-sqlite3")(":memory:"); db.exec("PRAGMA auto_vacuum = none"); diff --git a/bench/northwind/deno_old.js b/bench/northwind/deno_old.js index 256a757..7f1fd3c 100644 --- a/bench/northwind/deno_old.js +++ b/bench/northwind/deno_old.js @@ -1,5 +1,5 @@ import { Database } from "https://deno.land/x/sqlite3@0.4.3/mod.ts"; -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../../node_modules/mitata/src/cli.mjs"; const db = new Database("./bench/northwind.sqlite"); diff --git a/bench/northwind/node.mjs b/bench/northwind/node.mjs index 0ae2728..a24dd82 100644 --- a/bench/northwind/node.mjs +++ b/bench/northwind/node.mjs @@ -1,5 +1,5 @@ import { bench, run } from "mitata"; -import { createRequire } from "module"; +import { createRequire } from "node:module"; const require = createRequire(import.meta.url); const db = require("better-sqlite3")("./bench/northwind.sqlite"); diff --git a/deno.json b/deno.json index e6f9715..ee130fb 100644 --- a/deno.json +++ b/deno.json @@ -27,12 +27,6 @@ "bench-bun:northwind": "bun run bench/northwind/bun.js" }, - "fmt": { - "exclude": [ - "sqlite" - ] - }, - "lint": { "exclude": ["bench"], "rules": { @@ -46,5 +40,10 @@ "explicit-module-boundary-types" ] } + }, + "compilerOptions": { + "types": [ + "./node_modules/bun-types/index.d.ts" + ] } } diff --git a/package.json b/package.json index 6d2443f..216ebdf 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,8 @@ "dependencies": { "better-sqlite3": "^7.6.2", "mitata": "^0.1.6" + }, + "devDependencies": { + "bun-types": "^1.2.14" } } diff --git a/src/statement.ts b/src/statement.ts index e1df083..d768c61 100644 --- a/src/statement.ts +++ b/src/statement.ts @@ -468,7 +468,13 @@ export class Statement> { )(getColumn); let status = sqlite3_step(handle); while (status === SQLITE3_ROW) { - result.push(getRowArray(handle, this.int64 ?? this.db.int64, this.parseJson ?? this.db.parseJson)); + result.push( + getRowArray( + handle, + this.int64 ?? this.db.int64, + this.parseJson ?? this.db.parseJson, + ), + ); status = sqlite3_step(handle); } if (status !== SQLITE3_DONE) { @@ -501,7 +507,13 @@ export class Statement> { )(getColumn); let status = sqlite3_step(handle); while (status === SQLITE3_ROW) { - result.push(getRowArray(handle, this.int64 ?? this.db.int64, this.parseJson ?? this.db.parseJson)); + result.push( + getRowArray( + handle, + this.int64 ?? this.db.int64, + this.parseJson ?? this.db.parseJson, + ), + ); status = sqlite3_step(handle); } if (!this.#hasNoArgs && !this.#bound && params.length) { @@ -514,9 +526,15 @@ export class Statement> { return result as T[]; } - #rowObjectFn: ((h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any) | undefined; + #rowObjectFn: + | ((h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any) + | undefined; - getRowObject(): (h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any { + getRowObject(): ( + h: Deno.PointerValue, + int64: boolean, + parseJson: boolean, + ) => any { if (!this.#rowObjectFn || !this.#unsafeConcurrency) { const columnNames = this.columnNames(); const getRowObject = new Function( @@ -733,7 +751,7 @@ export class Statement> { /** Iterate over resultant rows from query. */ *iter(...params: RestBindParameters): IterableIterator { - this.#begin(); + this.#begin(); this.#bindAll(params); const getRowObject = this.getRowObject(); const int64 = this.int64 ?? this.db.int64;