All files / base64/src fromBase64.ts

100% Statements 8/8
66.66% Branches 4/6
100% Functions 2/2
100% Lines 7/7

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 111x 1x 1x   58x 1x   1x   100x  
import {bufferToUint8Array} from './util/buffers/bufferToUint8Array';
import {hasBuffer} from './constants';
import {createFromBase64} from './createFromBase64';
 
const fromBase64Cpp = hasBuffer ? (encoded: string) => bufferToUint8Array(Buffer.from(encoded, 'base64')) : null;
const fromBase64Native = createFromBase64();
 
export const fromBase64 = !fromBase64Cpp
  ? fromBase64Native
  : (encoded: string): Uint8Array => (encoded.length > 48 ? fromBase64Cpp(encoded) : fromBase64Native(encoded));