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.

27 lines (26 loc) • 1.04 kB
var gameGrouper_default = { getMultiTrackDiscCommonName: (romName) => romName.replace(/ ?\(Track [0-9]+\)/i, "").replace(/ ?\(Track [0-9]+ of [0-9]+\)/i, ""), getMultiDiscCommonName(gameName) { return this.getMultiTrackDiscCommonName(gameName).replace(/ ?\(Dis[ck] [0-9]+\)/i, "").replace(/ ?\(Dis[ck] [0-9]+ of [0-9]+\)/i, ""); }, /** * Given an array of objects that contain {@link Game}s, and a function to fetch those * {@link Game}s' names, group those objects together with the disc numbers stripped. */ groupMultiDiscGames(values, gameNameMapper) { return values.reduce((map, value) => { const gameName = gameNameMapper(value); const gameNameStripped = this.getMultiDiscCommonName(gameName); if (map.has(gameNameStripped)) { map.get(gameNameStripped)?.push(value); } else { map.set(gameNameStripped, [value]); } return map; }, /* @__PURE__ */ new Map()); } }; export { gameGrouper_default as default }; //# sourceMappingURL=gameGrouper.js.map