INNER CODE UNIT · TypeScript

createFile

WorldQL/dreamlab-engine · editor/client/main.ts:66

export async function createFile(fileName: string, file: File | string, no_restart = false) {
  function isTextFile(mimeType: string): boolean {
    const textTypes = [
      "text/",
      "application/json",
      "application/javascript",
      "application/xml",
      "application/x-httpd-php",
    ];
    return textTypes.some(type => mimeType.startsWith(type));
  }

  let content: string | ArrayBuffer;

  if (typeof file === "string") {
    content = file;
  } else {
    const isText = isTextFile(file.type);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…