@azure/communication-call-automation
Version:
Azure client library for Azure Communication Call Automation services
32 lines • 1.11 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeUTF8 = void 0;
exports.encodeUTF8fromBase64 = encodeUTF8fromBase64;
exports.encodeBase64 = encodeBase64;
const encodeUTF8 = (str) => new TextEncoder().encode(str);
exports.encodeUTF8 = encodeUTF8;
function encodeUTF8fromBase64(str) {
if (typeof atob !== "function") {
throw new Error("Your browser environment is missing the global `atob` function");
}
const binary = atob(str);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
return bytes;
}
function encodeBase64(value) {
if (typeof btoa !== "function") {
throw new Error("Your browser environment is missing the global `btoa` function");
}
const bytes = new Uint8Array(value);
let binary = "";
for (const byte of bytes) {
binary += String.fromCharCode(byte);
}
return btoa(binary);
}
//# sourceMappingURL=encodeUtils.browser.js.map