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.
70 lines (69 loc) • 2.2 kB
JavaScript
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 { Memoize } from "typescript-memoize";
const _WriteCandidate = class _WriteCandidate {
game;
romsWithFiles;
constructor(game, romsWithFiles) {
this.game = game;
this.romsWithFiles = romsWithFiles;
}
// Property getters
getGame() {
return this.game;
}
getRomsWithFiles() {
return this.romsWithFiles;
}
// Computed getters
getName() {
return this.game.getName();
}
/**
* Returns true if any {@link ROMWithFiles} input {@link File} has a {@link Patch} attached to it.
*/
isPatched() {
return this.getRomsWithFiles().some(
(romWithFiles) => romWithFiles.getInputFile().getPatch() !== void 0
);
}
canWrite() {
return this.romsWithFiles.every(
(romWithFiles) => romWithFiles.getInputFile().getCanBeCandidateInput()
);
}
// Immutable setters
withGame(game) {
return new _WriteCandidate(game, this.romsWithFiles);
}
withRomsWithFiles(romsWithFiles) {
if (romsWithFiles === this.romsWithFiles || romsWithFiles.length === this.romsWithFiles.length && romsWithFiles.every((rwf, idx) => this.romsWithFiles[idx] === rwf)) {
return this;
}
return new _WriteCandidate(this.game, romsWithFiles);
}
hashCode() {
let hashCode = this.game.hashCode();
hashCode += `|${this.romsWithFiles.map((romWithFiles) => romWithFiles.hashCode()).toSorted((a, b) => a.localeCompare(b)).join(",")}`;
return hashCode;
}
};
__decorateClass([
Memoize()
], _WriteCandidate.prototype, "canWrite", 1);
__decorateClass([
Memoize()
], _WriteCandidate.prototype, "hashCode", 1);
let WriteCandidate = _WriteCandidate;
export {
WriteCandidate as default
};
//# sourceMappingURL=writeCandidate.js.map