Files
awesome-copilot/extensions/draw/public/util.js
T

14 lines
536 B
JavaScript

export const esc = (s) =>
String(s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
export const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
export async function blobToBase64(blob) {
const bytes = new Uint8Array(await blob.arrayBuffer());
let s = "";
for (let i = 0; i < bytes.length; i += 0x8000) s += String.fromCharCode.apply(null, bytes.subarray(i, i + 0x8000));
return btoa(s);
}
export const fileName = (p) => String(p).split(/[\\/]/).pop();