Skip to content

Commit 249288e

Browse files
authored
Merge pull request #3 from Mause/external-buffers
fix: don't use external buffers on platforms without support
2 parents 9bb8060 + 300279c commit 249288e

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all: build
22

33
./node_modules:
4-
npm install --build-from-source
4+
npm install --ignore-scripts
55

66
build: ./node_modules
77
./node_modules/.bin/node-pre-gyp build -j max --loglevel=silent

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"gypfile": true,
88
"dependencies": {
99
"@mapbox/node-pre-gyp": "^1.0.0",
10-
"node-addon-api": "*",
10+
"node-addon-api": "^7.0.0",
1111
"node-gyp": "^9.3.0"
1212
},
1313
"binary": {

src/statement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ struct RunPreparedTask : public Task {
377377
// query results, the string data is owned by the QueryResult
378378
auto result_ref_ptr = new std::shared_ptr<duckdb::QueryResult>(result_ptr);
379379

380-
auto array_buffer =
381-
Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, result_ref_ptr);
380+
auto array_buffer = Napi::Buffer<char>::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(),
381+
deleter, result_ref_ptr);
382382

383-
auto typed_array = Napi::Uint8Array::New(env, blob.GetSize(), array_buffer, 0);
383+
auto typed_array = Napi::TypedArrayOf<char>(env, array_buffer);
384384

385385
// TODO we should handle this in duckdb probably
386386
if (is_header) {
@@ -708,7 +708,7 @@ struct GetNextArrowIpcTask : public Task {
708708
delete static_cast<unique_ptr<duckdb::DataChunk> *>(hint);
709709
};
710710
auto array_buffer =
711-
Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr);
711+
Napi::Buffer<char>::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr);
712712

713713
deferred.Resolve(array_buffer);
714714
}

0 commit comments

Comments
 (0)