UNPKG

@azure/cosmos

Version:
25 lines 780 B
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. export function hexStringToUint8Array(hex) { const arr = new Uint8Array(hex.length / 2); for (let i = 0; i < hex.length; i += 2) { arr[i / 2] = parseInt(hex.substr(i, 2), 16); } return arr; } export function uint8ArrayToHex(arr) { return Array.from(arr) .map((byte) => ("00" + byte.toString(16)).slice(-2)) .join(""); } export function concatUint8Arrays(arrays) { const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0); const result = new Uint8Array(totalLength); let offset = 0; for (const arr of arrays) { result.set(arr, offset); offset += arr.length; } return result; } //# sourceMappingURL=uint8.js.map