@azure/core-client
Version:
Core library for interfacing with AutoRest generated code
36 lines • 1.03 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { stringToUint8Array, uint8ArrayToString } from "@azure/core-util";
/**
* Encodes a string in base64 format.
* @param value - the string to encode
* @internal
*/
export function encodeString(value) {
return uint8ArrayToString(stringToUint8Array(value, "utf-8"), "base64");
}
/**
* Encodes a byte array in base64 format.
* @param value - the Uint8Array to encode
* @internal
*/
export function encodeByteArray(value) {
return uint8ArrayToString(value, "base64");
}
/**
* Decodes a base64 string into a byte array.
* @param value - the base64 string to decode
* @internal
*/
export function decodeString(value) {
return stringToUint8Array(value, "base64");
}
/**
* Decodes a base64 string into a string.
* @param value - the base64 string to decode
* @internal
*/
export function decodeStringToString(value) {
return uint8ArrayToString(stringToUint8Array(value, "base64"), "utf-8");
}
//# sourceMappingURL=base64.js.map