mirror of
https://github.com/github/awesome-copilot.git
synced 2026-10-13 15:24:25 +00:00
14 lines
536 B
JavaScript
14 lines
536 B
JavaScript
export const esc = (s) =>
|
|
String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[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();
|