All files / json-pack/src/util/buffers toDataUri.ts

42.85% Statements 3/7
100% Branches 0/0
0% Functions 0/1
40% Lines 2/5

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 812x   12x          
import {toBase64} from '@jsonjoy.com/base64/lib/toBase64';
 
export const toDataUri = (buf: Uint8Array, params?: Record<string, string | number>): string => {
  let uri = 'data:application/octet-stream;base64';
  for (const key in params) uri += `;${key}=${params[key]}`;
  return uri + ',' + toBase64(buf);
};