Permalink
Cannot retrieve contributors at this time
35 lines (35 sloc)
1.04 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@azure/core-util/dist-esm/src/base64.browser.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) Microsoft Corporation. | |
// Licensed under the MIT license. | |
/** | |
* Converts a base64 string into a byte array. | |
* @param content - The base64 string to convert. | |
* @internal | |
*/ | |
export function base64ToBytes(content) { | |
if (typeof atob !== "function") { | |
throw new Error(`Your browser environment is missing the global "atob" function.`); | |
} | |
const binary = atob(content); | |
const bytes = new Uint8Array(binary.length); | |
for (let i = 0; i < binary.length; i++) { | |
bytes[i] = binary.charCodeAt(i); | |
} | |
return bytes; | |
} | |
/** | |
* Converts an ArrayBuffer to base64 string. | |
* @param buffer - Raw binary data. | |
* @internal | |
*/ | |
export function bufferToBase64(buffer) { | |
if (typeof btoa !== "function") { | |
throw new Error(`Your browser environment is missing the global "btoa" function.`); | |
} | |
const bytes = new Uint8Array(buffer); | |
let binary = ""; | |
for (const byte of bytes) { | |
binary += String.fromCharCode(byte); | |
} | |
return btoa(binary); | |
} | |
//# sourceMappingURL=base64.browser.js.map |