@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
51 lines (50 loc) • 1.78 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var uint8_exports = {};
__export(uint8_exports, {
concatUint8Arrays: () => concatUint8Arrays,
hexStringToUint8Array: () => hexStringToUint8Array,
uint8ArrayToHex: () => uint8ArrayToHex
});
module.exports = __toCommonJS(uint8_exports);
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;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
concatUint8Arrays,
hexStringToUint8Array,
uint8ArrayToHex
});