All files / src/apis/shared/platform/decode decode.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44              6x 1x                   6x 5x                   6x 10x                   6x 49x    
/**
 *
 *
 * @export
 * @param {string} base64
 * @return {Uint8Array} Uint8Array
 */
export function base64ToUint8Array(base64: string): Uint8Array {
  return Buffer.from(base64, "base64");
}
 
/**
 *
 *
 * @export
 * @param {string} hex
 * @return {Uint8Array} Uint8Array
 */
export function hexToUint8Array(hex: string): Uint8Array {
  return Buffer.from(hex, "hex");
}
 
/**
 *
 *
 * @export
 * @param {string} text
 * @return {Uint8Array} Uint8Array
 */
export function utf8ToUint8Array(text: string): Uint8Array {
  return new Uint8Array(Buffer.from(text));
}
 
/**
 *
 *
 * @export
 * @param {Uint8Array} array
 * @return {string} string
 */
export function uint8ArrayToUtf8(array: Uint8Array): string {
  return Buffer.from(array).toString();
}