All files / src/components/music/helpers storage.ts

0% Statements 0/18
0% Branches 0/5
0% Functions 0/2
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                                               
/* eslint-disable camelcase */
/* eslint-disable import/no-unresolved */
/* eslint-disable import/no-webpack-loader-syntax */
 
import hardware_inc from "!!raw-loader!./hUGEDriver/include/hardware.inc";
import hUGEDriver_asm from "!!raw-loader!./hUGEDriver/hUGEDriver.asm";
import hUGE_inc from "!!raw-loader!./hUGEDriver/include/hUGE.inc";
import hUGE_note_table_inc from "!!raw-loader!./hUGEDriver/include/hUGE_note_table.inc";
import player_asm from "!!raw-loader!./hUGEDriver/player.asm";
 
const files = {
  "include/hardware.inc": hardware_inc,
  "include/hUGE.inc": hUGE_inc,
  "include/hUGE_note_table.inc": hUGE_note_table_inc,
  "hUGEDriver.asm": hUGEDriver_asm,
  "player.asm": player_asm,
} as Record<string, Uint8Array | string>;
 
const getFiles = () => files;
 
const update = (name: string, code: ArrayBuffer | string | null) => {
  Iif (typeof name !== "undefined") {
    if (code === null) {
      delete files[name];
    } else if (code instanceof ArrayBuffer) {
      files[name] = new Uint8Array(code);
    } else {
      files[name] = code;
    }
  }
  localStorage.rgbds_storage = JSON.stringify(files);
};
 
const storage = {
  update,
  getFiles,
};
 
export default storage;