UNPKG

igir

Version:

🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.

90 lines (89 loc) • 2.54 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; import "reflect-metadata"; import { Expose, plainToClassFromExist, Transform, Type } from "class-transformer"; import DAT from "../dat.js"; import Game from "../game.js"; import Header from "./header.js"; const _LogiqxDAT = class _LogiqxDAT extends DAT { header; game; machine; constructor(props) { super(props); this.header = props?.header; this.game = props?.games; this.machine = props?.machine; this.generateGameNamesToParents(); } /** * Construct a {@link LogiqxDAT} from a generic object, such as one from reading an XML file. */ static fromObject(obj, props) { const dat = new _LogiqxDAT(props); return plainToClassFromExist(dat, obj, { enableImplicitConversion: true, excludeExtraneousValues: true }).generateGameNamesToParents(); } // Property getters getHeader() { return this.header ?? new Header(); } getGames() { if (Array.isArray(this.game)) { if (this.game.length > 0) { return this.game; } } else if (this.game) { return [this.game]; } if (Array.isArray(this.machine)) { if (this.machine.length > 0) { return this.machine; } } else if (this.machine) { return [this.machine]; } return []; } /** * @inheritdoc */ isMame() { if (Array.isArray(this.machine)) { return this.machine.length > 0; } return this.machine !== void 0; } withGames(games) { return this.isMame() ? new _LogiqxDAT({ ...this, games: void 0, machine: games }) : new _LogiqxDAT({ ...this, games, machine: void 0 }); } }; __decorateClass([ Expose(), Type(() => Header) ], _LogiqxDAT.prototype, "header", 2); __decorateClass([ Expose(), Type(() => Game), Transform(({ value }) => value ?? []) ], _LogiqxDAT.prototype, "game", 2); __decorateClass([ Expose(), Type(() => Game), Transform(({ value }) => value ?? []) ], _LogiqxDAT.prototype, "machine", 2); let LogiqxDAT = _LogiqxDAT; export { LogiqxDAT as default }; //# sourceMappingURL=logiqxDat.js.map