[feat] add shared lib build script
This commit is contained in:
parent
9572a7e549
commit
849dbff420
|
@ -23,11 +23,11 @@ static Napi::Object RowIterator(const Napi::CallbackInfo& args) {
|
||||||
free(next);
|
free(next);
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
auto free_iter = [=](const Napi::CallbackInfo& a){
|
auto cleanup = [=](const Napi::CallbackInfo& a){
|
||||||
FreeIter(iter);
|
FreeIter(iter);
|
||||||
};
|
};
|
||||||
it.Set("next", Napi::Function::New(env, next_row));
|
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;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
type RowIterator = {
|
type RowIterator = {
|
||||||
next: () => Buffer;
|
next: () => Buffer;
|
||||||
free: () => void;
|
cleanup: () => void;
|
||||||
};
|
};
|
||||||
type SQLite = {
|
type SQLite = {
|
||||||
initSQLite: (pragmas: Buffer) => void;
|
initSQLite: (pragmas: Buffer) => void;
|
||||||
|
|
|
@ -35,9 +35,8 @@ const {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function initSQLite(pragmas: string) {
|
function initSQLite(pragmas: Buffer) {
|
||||||
const buf = Buffer.from(pragmas);
|
InitSQLite(ptr(pragmas));
|
||||||
InitSQLite(ptr(buf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowIterator(buf: Buffer) {
|
function rowIterator(buf: Buffer) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default class CBuilder<
|
||||||
const response = iter.next();
|
const response = iter.next();
|
||||||
const rows = decodeRows(response);
|
const rows = decodeRows(response);
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
iter.free();
|
iter.cleanup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
|
|
Loading…
Reference in a new issue