aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/bindings/node_util_types.cpp2
-rw-r--r--src/bun.js/util.exports.js7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/bun.js/bindings/node_util_types.cpp b/src/bun.js/bindings/node_util_types.cpp
index 54fcca78b..bf135ed0b 100644
--- a/src/bun.js/bindings/node_util_types.cpp
+++ b/src/bun.js/bindings/node_util_types.cpp
@@ -84,7 +84,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSymbolObject, (JSC::JSGlobalObject * global
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
- return JSValue::encode(jsBoolean(value.isCell() && jsDynamicCast<ErrorInstance*>(value) != nullptr));
+ return JSValue::encode(jsBoolean(value.isCell() && (value.inherits<JSC::ErrorInstance>() || value.asCell()->type() == ErrorInstanceType)));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsRegExp, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
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 || {}))
);
}