Skip to content

Commit

Permalink
Guard Buffer.prototype.latin1Slice as well
Browse files Browse the repository at this point in the history
Not sure if Deno/Bun implement Buffer, but latin1Slice borders on an
implementation detail since it isn't mentioned in the docs, so we should
make sure it exists before using it.
  • Loading branch information
valadaptive committed Sep 13, 2024
1 parent 06b8038 commit 6d6c595
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ if (typeof Buffer === 'function') {
}

let bufferToBinaryString;
if (typeof Buffer === 'function') {
if (typeof Buffer === 'function' && typeof Buffer.prototype.latin1Slice === 'function') {
bufferToBinaryString = function(buf) {
return Buffer.prototype.latin1Slice.call(buf);
};
Expand Down

0 comments on commit 6d6c595

Please sign in to comment.