二进制到可比较
将 TypedArray 或 ArrayBuffer 转换为可以在 Map 中用于比较的字符串,以查看字节是否相同。
// Turns a TypedArray or ArrayBuffer into a string that can be used for comparison
// in a Map to see if the bytes are the same.
//
export default function binaryToComparableString(
view: $ArrayBufferView,
): string {
return String.fromCharCode.apply(
String,
new Uint8Array(view.buffer, view.byteOffset, view.byteLength),
);
}