mwg API
    Preparing search index...

    Function readReplayFile

    • Reads a chosen file (or any Blob) as text, headless and in the browser alike: the browser half of an import is the picker, this is the rest. Blob.text() needs no DOM, so the same function reads a node:fs buffer's Blob in a tool.

      Parameters

      • file: Blob

      Returns Promise<string>

      import { importReplayFile, readReplayFile, version } from '@datamoc/mwg';

      declare const file: Blob; // from pickReplayFile, or a Node-side Blob
      const json = await readReplayFile(file);
      const replay = importReplayFile(json, { framework: version, game: 'my-game' });