-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was needed in a previous version of the parser, which used msgpack to encode the payload. Blobs (and Files) will now be included in the array of binary attachments without any additional transformation. Breaking change: the encode method is now synchronous See also 299849b
- Loading branch information
1 parent
fe33ff7
commit 28d4f03
Showing
6 changed files
with
77 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const withNativeBuffer: boolean = | ||
typeof Buffer === "function" && typeof Buffer.isBuffer === "function"; | ||
const withNativeArrayBuffer: boolean = typeof ArrayBuffer === "function"; | ||
|
||
const isView = (obj: any) => { | ||
return typeof ArrayBuffer.isView === "function" | ||
? ArrayBuffer.isView(obj) | ||
: obj.buffer instanceof ArrayBuffer; | ||
}; | ||
|
||
const toString = Object.prototype.toString; | ||
const withNativeBlob = | ||
typeof Blob === "function" || | ||
(typeof Blob !== "undefined" && | ||
toString.call(Blob) === "[object BlobConstructor]"); | ||
const withNativeFile = | ||
typeof File === "function" || | ||
(typeof File !== "undefined" && | ||
toString.call(File) === "[object FileConstructor]"); | ||
|
||
/** | ||
* Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File. | ||
* | ||
* @private | ||
*/ | ||
|
||
export default function isBinary(obj: any) { | ||
return ( | ||
(withNativeBuffer && Buffer.isBuffer(obj)) || | ||
(withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) || | ||
(withNativeBlob && obj instanceof Blob) || | ||
(withNativeFile && obj instanceof File) | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters