mirror of
https://github.com/Blah-IM/typescript-core.git
synced 2025-04-30 16:21:10 +00:00
fix: array buffer typing
This commit is contained in:
parent
a10a49152e
commit
598ed931e0
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
export function bufToHex(buf: ArrayBufferLike): string {
|
||||
return [...new Uint8Array(buf)].map((x) => x.toString(16).padStart(2, "0"))
|
||||
export function bufToHex(buf: ArrayBufferLike | Uint8Array): string {
|
||||
const u8Array = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
|
||||
return [...u8Array].map((x) => x.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue