diff --git a/binding/dal.cc b/binding/dal.cc index 911d415..62ea769 100644 --- a/binding/dal.cc +++ b/binding/dal.cc @@ -23,11 +23,11 @@ static Napi::Object RowIterator(const Napi::CallbackInfo& args) { free(next); return val; }; - auto free_iter = [=](const Napi::CallbackInfo& a){ + auto cleanup = [=](const Napi::CallbackInfo& a){ FreeIter(iter); }; it.Set("next", Napi::Function::New(env, next_row)); - it.Set("free", Napi::Function::New(env, free_iter)); + it.Set("cleanup", Napi::Function::New(env, cleanup)); return it; } diff --git a/dal/Binding.ts b/dal/Binding.ts index f58abf6..2355f26 100644 --- a/dal/Binding.ts +++ b/dal/Binding.ts @@ -2,7 +2,7 @@ import { createRequire } from "node:module"; const require = createRequire(import.meta.url); type RowIterator = { next: () => Buffer; - free: () => void; + cleanup: () => void; }; type SQLite = { initSQLite: (pragmas: Buffer) => void; diff --git a/dal/Bunding.ts b/dal/Bunding.ts index 5fa7486..a6d8596 100644 --- a/dal/Bunding.ts +++ b/dal/Bunding.ts @@ -35,9 +35,8 @@ const { }, }); -function initSQLite(pragmas: string) { - const buf = Buffer.from(pragmas); - InitSQLite(ptr(buf)); +function initSQLite(pragmas: Buffer) { + InitSQLite(ptr(pragmas)); } function rowIterator(buf: Buffer) { diff --git a/dal/node.napi.ts b/dal/node.napi.ts index 9efe9f3..dd6eea5 100644 --- a/dal/node.napi.ts +++ b/dal/node.napi.ts @@ -27,7 +27,7 @@ export default class CBuilder< const response = iter.next(); const rows = decodeRows(response); if (rows.length === 0) { - iter.free(); + iter.cleanup(); break; } for (const row of rows) {