-
-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): make isBuffer browser compliant
Closes: #2480
- Loading branch information
Showing
5 changed files
with
28 additions
and
39 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 |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import {nameOf} from "./nameOf"; | ||
|
||
/** | ||
* Tests to see if the object is Buffer | ||
* @param target | ||
* @returns {boolean} | ||
*/ | ||
export function isBuffer(target: any): target is Buffer { | ||
return !!(target && (target === Buffer || target instanceof Buffer)); | ||
// is Class | ||
if (target && "isBuffer" in target && typeof target.isBuffer === "function") { | ||
return true; | ||
} | ||
|
||
return isUint8Array(target); | ||
} | ||
|
||
export function isUint8Array(target: any): target is Uint8Array { | ||
return !!(target && (target === Uint8Array || target instanceof Uint8Array)); | ||
} |
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