diff options
| author | TheMas3212 <mas3212@gmail.com> | 2025-02-02 17:34:27 +1100 |
|---|---|---|
| committer | TheMas3212 <mas3212@gmail.com> | 2025-02-02 17:34:27 +1100 |
| commit | 981a5a2c7edecc2239dda1bc3321003f939a7450 (patch) | |
| tree | e328af15169d75ead4ce262f1cae36a2be6ba6d4 /src | |
| parent | acf7a79d0e6d3d09f4fc029d3eb35dd905d2b3ea (diff) | |
| download | tasd-js-981a5a2c7edecc2239dda1bc3321003f939a7450.tar.gz tasd-js-981a5a2c7edecc2239dda1bc3321003f939a7450.zip | |
Apply and fix new eslint ruleset
Diffstat (limited to 'src')
| -rw-r--r-- | src/constants.ts | 80 | ||||
| -rw-r--r-- | src/file.ts | 12 | ||||
| -rw-r--r-- | src/lib.ts | 6 | ||||
| -rw-r--r-- | src/packets/general.ts | 6 | ||||
| -rw-r--r-- | src/packets/index.ts | 12 | ||||
| -rw-r--r-- | src/utils.ts | 8 |
6 files changed, 62 insertions, 62 deletions
diff --git a/src/constants.ts b/src/constants.ts index 44c763f..906a73b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,54 +1,54 @@ export const PACKET_TYPES = { // General Keys - 'CONSOLE_TYPE': 0x0001, - 'CONSOLE_REGION': 0x0002, - 'GAME_TITLE': 0x0003, - 'ROM_NAME': 0x0004, - 'ATTRIBUTION': 0x0005, - 'CATEGORY': 0x0006, - 'EMULATOR_NAME': 0x0007, - 'EMULATOR_VERSION': 0x0008, - 'EMULATOR_CORE': 0x0009, - 'TAS_LAST_MODIFIED': 0x000A, - 'DUMP_CREATED': 0x000B, - 'DUMP_LAST_MODIFIED': 0x000C, - 'TOTAL_FRAMES': 0x000D, - 'RERECORDS': 0x000E, - 'SOURCE_LINK': 0x000F, - 'BLANK_FRAMES': 0x0010, - 'VERIFIED': 0x0011, - 'MEMORY_INIT': 0x0012, - 'GAME_IDENTIFIER': 0x0013, - 'MOVIE_LICENSE': 0x0014, - 'MOVIE_FILE': 0x0015, - 'PORT_CONTROLLER': 0x00F0, - 'PORT_OVERREAD': 0x00F1, + "CONSOLE_TYPE": 0x0001, + "CONSOLE_REGION": 0x0002, + "GAME_TITLE": 0x0003, + "ROM_NAME": 0x0004, + "ATTRIBUTION": 0x0005, + "CATEGORY": 0x0006, + "EMULATOR_NAME": 0x0007, + "EMULATOR_VERSION": 0x0008, + "EMULATOR_CORE": 0x0009, + "TAS_LAST_MODIFIED": 0x000A, + "DUMP_CREATED": 0x000B, + "DUMP_LAST_MODIFIED": 0x000C, + "TOTAL_FRAMES": 0x000D, + "RERECORDS": 0x000E, + "SOURCE_LINK": 0x000F, + "BLANK_FRAMES": 0x0010, + "VERIFIED": 0x0011, + "MEMORY_INIT": 0x0012, + "GAME_IDENTIFIER": 0x0013, + "MOVIE_LICENSE": 0x0014, + "MOVIE_FILE": 0x0015, + "PORT_CONTROLLER": 0x00F0, + "PORT_OVERREAD": 0x00F1, // NES Specific Keys - 'NES_LATCH_FILTER': 0x0101, - 'NES_CLOCK_FILTER': 0x0102, - 'NES_GAME_GENIE_CODE': 0x0104, + "NES_LATCH_FILTER": 0x0101, + "NES_CLOCK_FILTER": 0x0102, + "NES_GAME_GENIE_CODE": 0x0104, // SNES Specific Keys - 'SNES_LATCH_FILTER': 0x0201, - 'SNES_CLOCK_FILTER': 0x0202, - 'SNES_GAME_GENIE_CODE': 0x0204, - 'SNES_LATCH_TRAIN': 0x0205, + "SNES_LATCH_FILTER": 0x0201, + "SNES_CLOCK_FILTER": 0x0202, + "SNES_GAME_GENIE_CODE": 0x0204, + "SNES_LATCH_TRAIN": 0x0205, // Genesis Specific Keys - 'GENESIS_GAME_GENIE_CODE': 0x0804, + "GENESIS_GAME_GENIE_CODE": 0x0804, // Input Frame/Timing Keys - 'INPUT_CHUNK': 0xFE01, - 'INPUT_MOMENT': 0xFE02, - 'TRANSITION': 0xFE03, - 'LAG_FRAME_CHUNK': 0xFE04, - 'MOVIE_TRANSITION': 0xFE05, + "INPUT_CHUNK": 0xFE01, + "INPUT_MOMENT": 0xFE02, + "TRANSITION": 0xFE03, + "LAG_FRAME_CHUNK": 0xFE04, + "MOVIE_TRANSITION": 0xFE05, // Extraneous Keys - 'COMMENT': 0xFF01, - 'EXPERIMENTAL': 0xFFFE, - 'UNSPECIFIED': 0xFFFF, + "COMMENT": 0xFF01, + "EXPERIMENTAL": 0xFFFE, + "UNSPECIFIED": 0xFFFF, } as const; export function packetName(key: number) { for (const name of Object.keys(PACKET_TYPES)) { if (PACKET_TYPES[name as keyof typeof PACKET_TYPES] === key) return name; } - return 'Unknown Packet ' + key.toString(16).toUpperCase(); + return "Unknown Packet " + key.toString(16).toUpperCase(); } diff --git a/src/file.ts b/src/file.ts index f95c8ff..139aa76 100644 --- a/src/file.ts +++ b/src/file.ts @@ -38,8 +38,8 @@ export class TASD { return concatUint8Array(packets); } pprint() { - console.log('VERSION', this.version); - console.log('G_KEYLEN', this.g_keylen); + console.log("VERSION", this.version); + console.log("G_KEYLEN", this.g_keylen); for (const packet of this.packets) { console.log(packet.toString()); } @@ -64,14 +64,14 @@ export class TASD { this.markDirty(); } static parseFile(buffer: Uint8Array) { - if (buffer.length < 7) throw new Error('Input Too Short'); + if (buffer.length < 7) throw new Error("Input Too Short"); for (let i = 0; i < TASD.MAGIC.length; i++) { - if (buffer[i] !== TASD.MAGIC[i]) throw new Error('Invalid Magic Bytes'); + if (buffer[i] !== TASD.MAGIC[i]) throw new Error("Invalid Magic Bytes"); } const version = readUint16(buffer, 4); - if (version !== 1) throw new Error('Unsupported Version'); + if (version !== 1) throw new Error("Unsupported Version"); const g_keylen = readUint8(buffer, 6); - if (g_keylen !== 2) throw new Error('G_KEYLEN not equal to 2, unsupported'); + if (g_keylen !== 2) throw new Error("G_KEYLEN not equal to 2, unsupported"); const file = new TASD(version, g_keylen); let index = 7; while (index < buffer.length) { @@ -1,3 +1,3 @@ -export { TASD } from './file'; -export * as Packet from './packets'; -export * as utils from './utils';
\ No newline at end of file +export { TASD } from "./file"; +export * as Packet from "./packets"; +export * as utils from "./utils";
\ No newline at end of file diff --git a/src/packets/general.ts b/src/packets/general.ts index e3a3862..f6b00dc 100644 --- a/src/packets/general.ts +++ b/src/packets/general.ts @@ -456,8 +456,8 @@ export class GameIdentiferPacket implements TASDPacket { return 2 + this.name.length + this.identifier.length; } static fromBuffer(buffer: Uint8Array) { - const type = readUint8(buffer, 0) - const base = readUint8(buffer, 1) + const type = readUint8(buffer, 0); + const base = readUint8(buffer, 1); const nlen = readUint8(buffer, 2); const name = readString(buffer, 3, nlen); const identifier = buffer.subarray(3 + nlen); @@ -565,7 +565,7 @@ export class PortControllerPacket implements TASDPacket { return buildBuffer(g_keylen, this.key, payload); } toString() { - return `PortController ${this.port}, 0x${this.type.toString(16).padStart(4, '0')}`; + return `PortController ${this.port}, 0x${this.type.toString(16).padStart(4, "0")}`; } static readonly CONTROLLER_TYPE = { NES_STANDARD_CONTROLLER: 0x0101, diff --git a/src/packets/index.ts b/src/packets/index.ts index a8ae2bd..07d12fb 100644 --- a/src/packets/index.ts +++ b/src/packets/index.ts @@ -8,12 +8,12 @@ import * as genesis from "./genesis"; import * as input from "./input"; import * as extra from "./extra"; -export * as General from './general'; -export * as NES from './nes'; -export * as SNES from './snes'; -export * as Genesis from './genesis'; -export * as Input from './input'; -export * as Extra from './extra'; +export * as General from "./general"; +export * as NES from "./nes"; +export * as SNES from "./snes"; +export * as Genesis from "./genesis"; +export * as Input from "./input"; +export * as Extra from "./extra"; export function parse(type: number, buffer: Uint8Array): TASDPacket { switch (type) { diff --git a/src/utils.ts b/src/utils.ts index e4024f0..3375155 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -22,7 +22,7 @@ export function readUintN(buffer: Uint8Array, index: number, n: number) { case 2: return readUint16(buffer, index); case 3: return readUint24(buffer, index); case 4: return readUint32(buffer, index); - default: throw new Error('Unsupported UInt size'); + default: throw new Error("Unsupported UInt size"); } } @@ -56,7 +56,7 @@ export function writeUintN(uint: number, buffer: Uint8Array, index: number, size case 2: return writeUint16(uint, buffer, index); case 3: return writeUint24(uint, buffer, index); case 4: return writeUint32(uint, buffer, index); - default: throw new Error('Unsupported UInt size'); + default: throw new Error("Unsupported UInt size"); } } @@ -65,7 +65,7 @@ export function minUInt(uint: number) { if (uint < 65536) return 2; if (uint < 16777216) return 3; if (uint < 4294967296) return 4; - throw new Error('Unsupported UInt size'); + throw new Error("Unsupported UInt size"); } export function concatUint8Array(arrays: Uint8Array[]): Uint8Array { @@ -82,7 +82,7 @@ export function concatUint8Array(arrays: Uint8Array[]): Uint8Array { return buffer; } -const decoder = new TextDecoder('utf8'); +const decoder = new TextDecoder("utf8"); const encoder = new TextEncoder(); export function readString(buffer: Uint8Array, index: number, length: number) { return decoder.decode(buffer.subarray(index, index+length)); |
