From 6d6c595098758af38da81f6ee5a97e78fb6b4aa5 Mon Sep 17 00:00:00 2001 From: valadaptive Date: Fri, 13 Sep 2024 05:13:25 -0400 Subject: [PATCH] Guard Buffer.prototype.latin1Slice as well 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. --- lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 2963a74f..82a08683 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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); };