UNPKG

@azure/cosmos

Version:
30 lines 981 B
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); exports.hexStringToUint8Array = hexStringToUint8Array; exports.uint8ArrayToHex = uint8ArrayToHex; exports.concatUint8Arrays = concatUint8Arrays; 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; } function uint8ArrayToHex(arr) { return Array.from(arr) .map((byte) => ("00" + byte.toString(16)).slice(-2)) .join(""); } 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