cmpro-dat
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

cmpro-dat

NPM Version License: MIT

A clrmamepro .dat format parser for Node.js.

Install

npm install cmpro-dat

Usage

DAT.parse

const DAT = require('cmpro-dat');

const text = `
clrmamepro (
  name "Nintendo - Super Nintendo Entertainment System"
  description "Nintendo - Super Nintendo Entertainment System"
)

game (
  comment "Chrono Trigger (Japan)"
  origin "Japan"
  rom ( crc 4D014C20 )
)

game (
  comment "Ultimate Mortal Kombat 3 (Europe)"
  origin "US"
  rom ( crc 1C4C54D2 )
)
`;

DAT.parse(text).then(data => {
  console.log(data);
});
// [
//   {
//     __type: 'clrmamepro',
//     name: 'Nintendo - Super Nintendo Entertainment System',
//     description: 'Nintendo - Super Nintendo Entertainment System'
//   },
//   {
//     __type: 'game',
//     comment: 'Chrono Trigger (Japan)',
//     origin: 'Japan',
//     rom: { crc: '4D014C20' }
//   },
//   {
//     __type: 'game',
//     comment: 'Ultimate Mortal Kombat 3 (Europe)',
//     origin: 'US',
//     rom: { crc: '1C4C54D2' }
//   }
// ]

DAT.stringify

const DAT = require('cmpro-dat');

const datString = DAT.stringify([
  {
    __type: 'clrmamepro',
    name: 'Nintendo - Super Nintendo Entertainment System',
    description: 'Nintendo - Super Nintendo Entertainment System',
  },
  {
    __type: 'game',
    comment: 'Chrono Trigger (Japan)',
    origin: 'Japan',
    rom: { crc: '4D014C20' },
  },
  {
    __type: 'game',
    comment: 'Ultimate Mortal Kombat 3 (Europe)',
    origin: 'US',
    rom: { crc: '1C4C54D2' },
  },
]);
// clrmamepro (
//   name "Nintendo - Super Nintendo Entertainment System"
//   description "Nintendo - Super Nintendo Entertainment System"
// )
//
// game (
//   comment "Chrono Trigger (Japan)"
//   origin Japan
//   rom (
//     crc "4D014C20"
//   )
// )
//
// game (
//   comment "Ultimate Mortal Kombat 3 (Europe)"
//   origin US
//   rom (
//     crc "1C4C54D2"
//   )
// )

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i cmpro-dat

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

42.8 kB

Total Files

6

Last publish

Collaborators

  • enten