aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/util.exports.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-08 17:18:02 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-08 17:18:02 -0800
commitddec9e0bf639ae2f672c71c228759f741f805735 (patch)
treeb07007dfd5716525761f08394e3092ee70efac34 /src/bun.js/util.exports.js
parent4962bea4fc269e537a8f505e2484d1bb289b8d9f (diff)
downloadbun-ddec9e0bf639ae2f672c71c228759f741f805735.tar.gz
bun-ddec9e0bf639ae2f672c71c228759f741f805735.tar.zst
bun-ddec9e0bf639ae2f672c71c228759f741f805735.zip
handle more cases with util.isErrorbun-v0.5.6
Diffstat (limited to 'src/bun.js/util.exports.js')
-rw-r--r--src/bun.js/util.exports.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bun.js/util.exports.js b/src/bun.js/util.exports.js
index c0adc0344..ce618784d 100644
--- a/src/bun.js/util.exports.js
+++ b/src/bun.js/util.exports.js
@@ -3,11 +3,16 @@ var __commonJS = (cb, mod) =>
function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
+
+function isBufferInterface({ copy, fill, readUint8 }) {
+ return typeof copy === "function" && typeof fill === "function" && typeof readUint8 === "function";
+}
+
export function isBuffer(value) {
return (
Buffer.isBuffer(value) ||
// incase it ends up as a browserify buffer
- (typeof arg?.copy === "function" && typeof arg?.fill === "function" && typeof arg?.readUInt8 === "function")
+ (typeof value === "object" && isBufferInterface(value || {}))
);
}