main
js 19 lines 543 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 // Turns a TypedArray or ArrayBuffer into a string that can be used for comparison
11 // in a Map to see if the bytes are the same.
12 export default function binaryToComparableString(
13 view: $ArrayBufferView,
14 ): string {
15 return String.fromCharCode.apply(
16 String,
17 new Uint8Array(view.buffer, view.byteOffset, view.byteLength),
18 );
19 }