You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use JSZip in Filer (https://github.com/js-platform/filer) and running into some issues. I've been moving our code over to use Buffer everywhere vs. Uint8Array for binary data, and with the way browserify augments a Uint8Array as a Buffer (e.g., by adding extra methods to the instance), you can loosen your check on when nodebuffers are supported (currently !process.browser). In a browserify build, Buffer will always be available, either as a native type (node.js) or as an augmented Uint8Array, etc. so in theory you should be able to let callers use nodebuffer no matter what environment they are in. Since you're using browserify, you get this for free, so you might want to consider it.
Instead of doing a type check, I'd suggest you look at the methods you need on Buffer, and just see if the passed data object supports what you'll call. Then you shouldn't care whether it's a Buffer or Uint8Array-pretending-to-be-a-Buffer.
The text was updated successfully, but these errors were encountered:
I'm trying to use JSZip in Filer (https://github.com/js-platform/filer) and running into some issues. I've been moving our code over to use Buffer everywhere vs. Uint8Array for binary data, and with the way browserify augments a Uint8Array as a Buffer (e.g., by adding extra methods to the instance), you can loosen your check on when nodebuffers are supported (currently
!process.browser
). In a browserify build, Buffer will always be available, either as a native type (node.js) or as an augmented Uint8Array, etc. so in theory you should be able to let callers use nodebuffer no matter what environment they are in. Since you're using browserify, you get this for free, so you might want to consider it.See https://github.com/feross/buffer
Instead of doing a type check, I'd suggest you look at the methods you need on Buffer, and just see if the passed
data
object supports what you'll call. Then you shouldn't care whether it's a Buffer or Uint8Array-pretending-to-be-a-Buffer.The text was updated successfully, but these errors were encountered: