INNER CODE UNIT · JavaScript

read

eugeneyan/obsidian-copilot · plugin/main.js:77

    async function read(reader, editor) {
      let buffer = "";
      const { value, done } = await reader.read();
      if (done) {
        statusBarItemEl.setText("Done with Copilot task!");
        return;
      }
      const decoded = new TextDecoder().decode(value);
      buffer += decoded;
      let start = 0;
      let end = buffer.indexOf("\n");
      while (end !== -1) {
        const message = buffer.slice(start, end);
        start = end + 1;
        try {
          const messageWithoutPrefix = message.replace("data: ", "");
          const json = JSON.parse(messageWithoutPrefix);
          let lastToken = "";

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…