We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d3e805f commit 7145012Copy full SHA for 7145012
1 file changed
lib/is-binary.ts
@@ -15,6 +15,8 @@ const withNativeFile =
15
typeof File === "function" ||
16
(typeof File !== "undefined" &&
17
toString.call(File) === "[object FileConstructor]");
18
+const withNativeBuffer =
19
+ typeof Buffer === "function" && typeof Buffer.isBuffer === "function";
20
21
/**
22
* Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
@@ -26,7 +28,8 @@ export function isBinary(obj: any) {
26
28
return (
27
29
(withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
30
(withNativeBlob && obj instanceof Blob) ||
- (withNativeFile && obj instanceof File)
31
+ (withNativeFile && obj instanceof File) ||
32
+ (withNativeBuffer && Buffer.isBuffer(obj))
33
);
34
}
35
0 commit comments