ps2-codes
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

PS2 Codes Quality assurance

Library for working with Playstation™ 2 cheat codes. Provides functions for reading cheat files and converting them to another available format.

Installation

The library is available as an npm package. To install, run the command:

npm install -s ps2-codes

Usage

Parsing

To parse a file, call the fromString function on the values of the formats object.

import { formats } from 'ps2-codes'
import { readFile } from 'fs/promises'

const content = await readFile('./input.raw', { encoding: 'utf8' })
const cheats = formats.raw.fromString(content)

// Print parsed cheats count
console.log(cheats.length)

Formatting

To generate a file from an array of cheats, use the toString method.

import { formats } from 'ps2-codes'
import { writeFile, readFile } from 'fs/promises'

const rawContent = await readFile('./input.raw', { encoding: 'utf8' })
const cheats = formats.raw.fromString(content)
const pnachContent = formats.pnach.toString(cheats)

// Write pnach
await writeFile('./output.pnach', pnachContent)

Assuming format

The library may try to determine the format of the input file itself. To do this, pass the content to the assumeFormat function.

import { formats, assumeFormat } from 'ps2-codes'

const content = `
//Infinite Health
20220E9C C6212AA8
20220EA4 E6212AD4
//Infinite Devil Trigger Usage
2021ECA0 00000000
//Max Infinite Devil Trigger
20244EA0 C60128C8
20244EB0 E60128C4`

const format = assumeFormat(content) // returns 'raw'
const cheats = formats[format].fromString(content)

Package Sidebar

Install

npm i ps2-codes

Weekly Downloads

0

Version

1.0.3

License

GPL-3.0

Unpacked Size

45.5 kB

Total Files

22

Last publish

Collaborators

  • mishamyrt