Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch shpjs@4.0.3 for the project I'm working on.
I ran into an issue when switching from jest to vitest. After some debugging, I figured out that my ArrayBuffer seems to be created in a different context and does not pass the instanceof check. I have adopted the check from https://github.com/fengyuanchen/is-array-buffer/blob/main/index.ts and it works again for me.
Here is the diff that solved my problem:
diff --git a/node_modules/shpjs/lib/index.js b/node_modules/shpjs/lib/index.js
index 7f8cda8..64d1419 100644
--- a/node_modules/shpjs/lib/index.js
+++ b/node_modules/shpjs/lib/index.js
@@ -23,7 +23,7 @@ function toBuffer (b) {
if (Buffer.isBuffer(b)) {
return b;
}
- if (b instanceof global.ArrayBuffer) {
+ if (b instanceof global.ArrayBuffer || Object.prototype.toString.call(b) === '[object ArrayBuffer]') {
return Buffer.from(b);
}
if (b.buffer instanceof global.ArrayBuffer) {
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
shpjs@4.0.3
for the project I'm working on.I ran into an issue when switching from jest to vitest. After some debugging, I figured out that my ArrayBuffer seems to be created in a different context and does not pass the instanceof check. I have adopted the check from https://github.com/fengyuanchen/is-array-buffer/blob/main/index.ts and it works again for me.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.