diff --git a/package.json b/package.json index 3e6675a..d335767 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "eslint-config-prettier": "^10.1.8", "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-import-x": "^4.16.2", - "eslint-plugin-unicorn": "^71.1.0", + "eslint-plugin-unicorn": "^72.0.0", "husky": "^9.1.7", "lint-staged": "^17.0.5", "prettier": "^3.8.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab087ef..c1b9406 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,8 +43,8 @@ importers: specifier: ^4.16.2 version: 4.17.1(@typescript-eslint/utils@8.64.0(@typescript/typescript6@6.0.2)(eslint@10.7.0))(eslint@10.7.0) eslint-plugin-unicorn: - specifier: ^71.1.0 - version: 71.1.0(eslint@10.7.0) + specifier: ^72.0.0 + version: 72.0.0(eslint@10.7.0) husky: specifier: ^9.1.7 version: 9.1.7 @@ -137,6 +137,10 @@ packages: resolution: {integrity: sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} + '@eslint/css-tree@4.0.4': + resolution: {integrity: sha512-nxMparyhqVWQvadx9x8dIfubfIPOE+X2b2waua8fzdnM9vdp9rgVtwEZlG0TmCwEUz/d/f40fzvO/eqBwdxz0A==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + '@eslint/js@10.0.1': resolution: {integrity: sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} @@ -1028,8 +1032,8 @@ packages: resolution: {integrity: sha512-tixWYgm5ZoOD+3g6UTea91eow5z6AAHaho3g0V9CNSNb45gM8SmflpAc+GRd1InC4AqN/07Unrgp56Y94N9hJQ==} engines: {node: '>=20.19.0'} - caniuse-lite@1.0.30001805: - resolution: {integrity: sha512-52noaS3DubycKSXaU30TwPGIp+POyQSUVa5jBEq3vkRkY0kjyb3LQgvhU6WGyCcyXqVLWO0Cw0Q6BSdD0kUfVA==} + caniuse-lite@1.0.30001806: + resolution: {integrity: sha512-72Cuvd95zbSYPKq6Fhg8eDJRlzgWDf7/mtoZv6Qe/DYNCEBdNxoA3+rZAU2ZhGCpZlns3EssFavaZomckT5Uuw==} chai@6.2.2: resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} @@ -1100,8 +1104,8 @@ packages: oxc-resolver: optional: true - electron-to-chromium@1.5.389: - resolution: {integrity: sha512-cEto7aeOqBfU1D+c5py5pE+ooscKE75JifxLBdFUZsqAxRS6y7kebtxAZvICszSl05gPjYHDTjY+lXpyGvpJbg==} + electron-to-chromium@1.5.393: + resolution: {integrity: sha512-kiDJdIUawuEIcp9XoICKp1iTYDEbgguIPq526N1Q7jIQDeQ3CqoMx71025PI/7E48Ddtw2HuWsVjY7afEgNxmg==} emoji-regex@10.6.0: resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==} @@ -1170,8 +1174,8 @@ packages: eslint-import-resolver-node: optional: true - eslint-plugin-unicorn@71.1.0: - resolution: {integrity: sha512-dn3YmR3qLLUeYyo/os3ubZ7UHQJ1WbBAgC9cIhnLTyMj9J6kivuc2U1fCmYetLexUlTDVYtBqhjSj/VaebTe6Q==} + eslint-plugin-unicorn@72.0.0: + resolution: {integrity: sha512-hqO6ksoOHO+ZhdseTuKRVQbx9U7PRO/cv8qAR1mctwzdVO2hYud8uS9luAhp43RJgziYgHAph8eHyipT8GL0ng==} engines: {node: '>=22'} peerDependencies: eslint: '>=10.4' @@ -1509,6 +1513,9 @@ packages: resolution: {integrity: sha512-RCEsPjR+sr0x+AuYp601tKTkgFG4YEPLCzHST3cQ/fhlJkqAkz1L2/Qbp1j9qw5SBwQHFBoW8+hoN5xssOF0Tw==} hasBin: true + mdn-data@2.28.1: + resolution: {integrity: sha512-U9w+PzSZ00Z5m9rZ5ARVFL5xOfuCHdKYi/1RRwDCJsboFgJDNT3zT6PIPD7mZQYaQLhsZM3GfDRgSMRHhSmVng==} + mdurl@2.0.0: resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} @@ -1594,8 +1601,8 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - postcss@8.5.19: - resolution: {integrity: sha512-Mz8SaolMd8nB+G13WkORcxQKHZ/NE4xXevtkJHVuG+guo9/wYKlIMTKAqGdEmYOXR2ijPjTYNHssizdaVSUNdQ==} + postcss@8.5.20: + resolution: {integrity: sha512-lW616l85ucIQL+FocMmL7pQFPqBmwejrCMg+iPxyImlrANNJG9NHq/RkyCZopDhd8C3LA03PHRJDjkbGu8vvug==} engines: {node: ^10 || ^12 || >=14} prelude-ls@1.2.1: @@ -2059,6 +2066,11 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 + '@eslint/css-tree@4.0.4': + dependencies: + mdn-data: 2.28.1 + source-map-js: 1.2.1 + '@eslint/js@10.0.1(eslint@10.7.0)': optionalDependencies: eslint: 10.7.0 @@ -2732,8 +2744,8 @@ snapshots: browserslist@4.28.6: dependencies: baseline-browser-mapping: 2.10.43 - caniuse-lite: 1.0.30001805 - electron-to-chromium: 1.5.389 + caniuse-lite: 1.0.30001806 + electron-to-chromium: 1.5.393 node-releases: 2.0.51 update-browserslist-db: 1.2.3(browserslist@4.28.6) @@ -2741,7 +2753,7 @@ snapshots: cac@7.0.0: {} - caniuse-lite@1.0.30001805: {} + caniuse-lite@1.0.30001806: {} chai@6.2.2: {} @@ -2788,7 +2800,7 @@ snapshots: dts-resolver@3.0.0: {} - electron-to-chromium@1.5.389: {} + electron-to-chromium@1.5.393: {} emoji-regex@10.6.0: {} @@ -2847,14 +2859,16 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-unicorn@71.1.0(eslint@10.7.0): + eslint-plugin-unicorn@72.0.0(eslint@10.7.0): dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@10.7.0) + '@eslint/css-tree': 4.0.4 browserslist: 4.28.6 change-case: 5.4.4 ci-info: 4.4.0 core-js-compat: 3.49.0 detect-indent: 7.0.2 + entities: 4.5.0 eslint: 10.7.0 find-up-simple: 1.0.1 globals: 17.7.0 @@ -2867,6 +2881,7 @@ snapshots: reserved-identifiers: 1.2.0 semver: 7.8.5 strip-indent: 4.1.1 + yaml: 2.9.0 eslint-scope@9.1.2: dependencies: @@ -3181,6 +3196,8 @@ snapshots: punycode.js: 2.3.1 uc.micro: 2.1.0 + mdn-data@2.28.1: {} + mdurl@2.0.0: {} mimic-function@5.0.1: {} @@ -3242,7 +3259,7 @@ snapshots: pluralize@8.0.0: {} - postcss@8.5.19: + postcss@8.5.20: dependencies: nanoid: 3.3.16 picocolors: 1.1.1 @@ -3540,7 +3557,7 @@ snapshots: dependencies: lightningcss: 1.32.0 picomatch: 4.0.5 - postcss: 8.5.19 + postcss: 8.5.20 rolldown: 1.0.3 tinyglobby: 0.2.17 optionalDependencies: diff --git a/src/stringify.ts b/src/stringify.ts index 07b4691..02424d1 100644 --- a/src/stringify.ts +++ b/src/stringify.ts @@ -54,9 +54,9 @@ function pad(value: string, length: number, align: 'left' | 'right'): string { return align === 'right' ? value.padStart(length) : value.padEnd(length); } -function writeAt(buf: string[], col: number, value: string): void { +function writeAt(buffer: string[], col: number, value: string): void { for (const [index, char] of [...value].entries()) { - buf[col + index] = char; + buffer[col + index] = char; } } @@ -106,8 +106,8 @@ function reconstructPlayerResults( if (game.forfeit === 'both') { result = '-'; } else if ( - (game.forfeit === 'black' && isWhite) || - (game.forfeit === 'white' && !isWhite) + (isWhite && game.forfeit === 'black') || + (!isWhite && game.forfeit === 'white') ) { // This player wins by forfeit result = '+'; @@ -121,8 +121,8 @@ function reconstructPlayerResults( if (game.result === 'draw') { result = isRated ? '=' : 'D'; } else if ( - (game.result === 'white' && isWhite) || - (game.result === 'black' && !isWhite) + (isWhite && game.result === 'white') || + (!isWhite && game.result === 'black') ) { // This player wins result = isRated ? '1' : 'W'; @@ -167,54 +167,58 @@ function stringifyPlayerLine( } // Build a character buffer pre-filled with spaces up to rank column end - const buf: string[] = Array.from({ length: COL_RANK + 5 }, () => ' '); + const buffer: string[] = Array.from({ length: COL_RANK + 5 }, () => ' '); // Record type - buf[0] = '0'; - buf[1] = '0'; - buf[2] = '1'; + buffer[0] = '0'; + buffer[1] = '0'; + buffer[2] = '1'; // Pairing number — use startingRank if available, otherwise numeric id const pairingNumber = player.startingRank ?? Number(player.id); - writeAt(buf, COL_PAIRING_NUMBER, pad(String(pairingNumber), 4, 'right')); + writeAt(buffer, COL_PAIRING_NUMBER, pad(String(pairingNumber), 4, 'right')); // Sex — single char at col 9 if (player.sex !== undefined) { - buf[COL_SEX] = player.sex; + buffer[COL_SEX] = player.sex; } // Title — left-aligned in 4 chars at col 10 if (player.title !== undefined) { - writeAt(buf, COL_TITLE, pad(player.title, 4, 'left')); + writeAt(buffer, COL_TITLE, pad(player.title, 4, 'left')); } // Name — left-aligned in 33 chars at col 14 const name = player.name ?? ''; warnIfTruncated(name, 'name', 33, COL_NAME); - writeAt(buf, COL_NAME, pad(name.slice(0, 33), 33, 'left')); + writeAt(buffer, COL_NAME, pad(name.slice(0, 33), 33, 'left')); // Rating — right-aligned in 4 chars at col 48 if (player.rating !== undefined) { - writeAt(buf, COL_RATING, pad(String(player.rating), 4, 'right')); + writeAt(buffer, COL_RATING, pad(String(player.rating), 4, 'right')); } // Federation — left-aligned in 3 chars at col 53 if (player.federation !== undefined) { warnIfTruncated(player.federation, 'federation', 3, COL_FEDERATION); - writeAt(buf, COL_FEDERATION, pad(player.federation.slice(0, 3), 3, 'left')); + writeAt( + buffer, + COL_FEDERATION, + pad(player.federation.slice(0, 3), 3, 'left'), + ); } // FIDE ID — left-aligned in 12 chars at col 57 if (player.fideId !== undefined) { warnIfTruncated(player.fideId, 'fideId', 12, COL_FIDE_ID); - writeAt(buf, COL_FIDE_ID, pad(player.fideId.slice(0, 12), 12, 'left')); + writeAt(buffer, COL_FIDE_ID, pad(player.fideId.slice(0, 12), 12, 'left')); } // Birth date — left-aligned in 10 chars at col 70 if (player.birthDate !== undefined) { warnIfTruncated(player.birthDate, 'birthDate', 10, COL_BIRTH_DATE); writeAt( - buf, + buffer, COL_BIRTH_DATE, pad(player.birthDate.slice(0, 10), 10, 'left'), ); @@ -222,10 +226,10 @@ function stringifyPlayerLine( // Points — right-aligned in 4 chars at col 80, always one decimal place const pointsString = player.points.toFixed(1); - writeAt(buf, COL_POINTS, pad(pointsString, 4, 'right')); + writeAt(buffer, COL_POINTS, pad(pointsString, 4, 'right')); // Rank — right-aligned in 5 chars at col 84 - writeAt(buf, COL_RANK, pad(String(player.rank), 5, 'right')); + writeAt(buffer, COL_RANK, pad(String(player.rank), 5, 'right')); // Round results — reconstruct from completedRounds const results = reconstructPlayerResults(player, data); @@ -238,8 +242,8 @@ function stringifyPlayerLine( const slot = ROUND_RESULTS_OFFSET + (result.round - 1) * ROUND_ENTRY_LENGTH; // Extend buffer if needed - while (buf.length < slot + ROUND_ENTRY_LENGTH) { - buf.push(' '); + while (buffer.length < slot + ROUND_ENTRY_LENGTH) { + buffer.push(' '); } const opponentString = @@ -247,15 +251,15 @@ function stringifyPlayerLine( ? '0000' : String(Number(result.opponentId)).padStart(4, ' '); const entry = `${opponentString} ${result.color} ${result.result} `; - writeAt(buf, slot, entry); + writeAt(buffer, slot, entry); } // Trim trailing spaces only up to the rounds section; keep round entries intact - const header = buf.slice(0, ROUND_RESULTS_OFFSET).join('').trimEnd(); - const rounds = buf.slice(ROUND_RESULTS_OFFSET).join(''); + const header = buffer.slice(0, ROUND_RESULTS_OFFSET).join('').trimEnd(); + const rounds = buffer.slice(ROUND_RESULTS_OFFSET).join(''); return header.padEnd(ROUND_RESULTS_OFFSET) + rounds; } - return buf.join('').trimEnd(); + return buffer.join('').trimEnd(); } export default function stringify( @@ -322,21 +326,21 @@ export default function stringify( } if (meta?.roundDates !== undefined && meta.roundDates.length > 0) { // Round dates occupy 10-char slots starting at col 91 (same as 001 round results). - const buf: string[] = Array.from( + const buffer: string[] = Array.from( { length: ROUND_RESULTS_OFFSET }, () => ' ', ); - buf[0] = '1'; - buf[1] = '3'; - buf[2] = '2'; + buffer[0] = '1'; + buffer[1] = '3'; + buffer[2] = '2'; for (const [index, date] of meta.roundDates.entries()) { const pos = ROUND_RESULTS_OFFSET + index * ROUND_ENTRY_LENGTH; - while (buf.length < pos + ROUND_ENTRY_LENGTH) { - buf.push(' '); + while (buffer.length < pos + ROUND_ENTRY_LENGTH) { + buffer.push(' '); } - writeAt(buf, pos, date.slice(0, 8)); + writeAt(buffer, pos, date.slice(0, 8)); } - lines.push(buf.join('').trimEnd()); + lines.push(buffer.join('').trimEnd()); } if (data.totalRounds > 0) { lines.push(`XXR ${data.totalRounds}`); @@ -463,35 +467,38 @@ export default function stringify( for (const player of data.players) { const nationalRatings = player.nationalRatings ?? []; for (const nrs of nationalRatings) { - const buf: string[] = Array.from({ length: COL_RANK + 5 }, () => ' '); + const buffer: string[] = Array.from( + { length: COL_RANK + 5 }, + () => ' ', + ); // Federation code as record type (3 chars) - writeAt(buf, 0, nrs.federation.slice(0, 3)); + writeAt(buffer, 0, nrs.federation.slice(0, 3)); const nrsPairingNumber = player.startingRank ?? Number(player.id); writeAt( - buf, + buffer, COL_PAIRING_NUMBER, pad(String(nrsPairingNumber), 4, 'right'), ); // NationalRating from @echecs/tournament has no sex field; use player's // sex for NRS records as per TRF26 spec if (player.sex !== undefined) { - buf[COL_SEX] = player.sex; + buffer[COL_SEX] = player.sex; } if (nrs.classification !== undefined) { writeAt( - buf, + buffer, COL_TITLE, pad(nrs.classification.slice(0, 3), 3, 'left'), ); } // Use player's name for the NRS record (TRF26 spec mirrors the player name) if (player.name !== undefined) { - writeAt(buf, COL_NAME, pad(player.name.slice(0, 33), 33, 'left')); + writeAt(buffer, COL_NAME, pad(player.name.slice(0, 33), 33, 'left')); } - writeAt(buf, COL_RATING, pad(String(nrs.rating), 4, 'right')); + writeAt(buffer, COL_RATING, pad(String(nrs.rating), 4, 'right')); if (nrs.nationalId !== undefined) { writeAt( - buf, + buffer, COL_FIDE_ID, pad(nrs.nationalId.slice(0, 12), 12, 'left'), ); @@ -499,12 +506,12 @@ export default function stringify( // Use player's birthDate for NRS records if (player.birthDate !== undefined) { writeAt( - buf, + buffer, COL_BIRTH_DATE, pad(player.birthDate.slice(0, 10), 10, 'left'), ); } - lines.push(buf.join('').trimEnd()); + lines.push(buffer.join('').trimEnd()); } } } @@ -526,23 +533,27 @@ export default function stringify( // XXP — Forbidden pairs (all versions; round sentinel 0/0) const prohibitedPairings = data.prohibitedPairings ?? []; for (const pp of prohibitedPairings) { - if (pp.firstRound === 0 && pp.lastRound === 0) { - const idPart = pp.playerIds.join(' '); - lines.push(`XXP ${idPart}`); + if (!(pp.firstRound === 0 && pp.lastRound === 0)) { + continue; } + + const idPart = pp.playerIds.join(' '); + lines.push(`XXP ${idPart}`); } // 260 — Prohibited pairings (TRF26 only) if (version === 'TRF26') { for (const pp of prohibitedPairings) { - if (pp.firstRound !== 0 || pp.lastRound !== 0) { - const idPart = pp.playerIds - .map((id) => String(Number(id)).padStart(4)) - .join(' '); - lines.push( - `260 ${String(pp.firstRound).padStart(3)} ${String(pp.lastRound).padStart(3)} ${idPart}`, - ); + if (pp.firstRound === 0 && pp.lastRound === 0) { + continue; } + + const idPart = pp.playerIds + .map((id) => String(Number(id)).padStart(4)) + .join(' '); + lines.push( + `260 ${String(pp.firstRound).padStart(3)} ${String(pp.lastRound).padStart(3)} ${idPart}`, + ); } } @@ -601,28 +612,28 @@ export default function stringify( if (version === 'TRF26') { const teams = data.teams ?? []; for (const team of teams) { - const buf: string[] = Array.from({ length: 72 }, () => ' '); - buf[0] = '3'; - buf[1] = '1'; - buf[2] = '0'; + const buffer: string[] = Array.from({ length: 72 }, () => ' '); + buffer[0] = '3'; + buffer[1] = '1'; + buffer[2] = '0'; const teamIdString = String(Number(team.id)); - writeAt(buf, 4, pad(teamIdString, 3, 'right')); - writeAt(buf, 8, pad(team.name.slice(0, 32), 32, 'left')); + writeAt(buffer, 4, pad(teamIdString, 3, 'right')); + writeAt(buffer, 8, pad(team.name.slice(0, 32), 32, 'left')); if (team.nickname !== undefined) { - writeAt(buf, 41, pad(team.nickname.slice(0, 5), 5, 'left')); + writeAt(buffer, 41, pad(team.nickname.slice(0, 5), 5, 'left')); } - writeAt(buf, 54, pad(team.matchPoints.toFixed(1), 6, 'right')); - writeAt(buf, 61, pad(team.gamePoints.toFixed(1), 6, 'right')); - writeAt(buf, 68, pad(String(team.rank), 3, 'right')); + writeAt(buffer, 54, pad(team.matchPoints.toFixed(1), 6, 'right')); + writeAt(buffer, 61, pad(team.gamePoints.toFixed(1), 6, 'right')); + writeAt(buffer, 68, pad(String(team.rank), 3, 'right')); for (const [index, id] of team.playerIds.entries()) { const pos = 73 + index * 5; - while (buf.length < pos + 4) { - buf.push(' '); + while (buffer.length < pos + 4) { + buffer.push(' '); } const idString = String(Number(id)); - writeAt(buf, pos, pad(idString, 4, 'right')); + writeAt(buffer, pos, pad(idString, 4, 'right')); } - lines.push(buf.join('').trimEnd()); + lines.push(buffer.join('').trimEnd()); } } @@ -631,24 +642,24 @@ export default function stringify( const teamRoundResults = options?.teamRoundResults ?? []; for (const record of teamRoundResults) { if (record.tag === '801') { - const buf801: string[] = Array.from({ length: 22 }, () => ' '); - writeAt(buf801, 0, '801'); + const buffer801: string[] = Array.from({ length: 22 }, () => ' '); + writeAt(buffer801, 0, '801'); const teamIdString801 = String(Number(record.teamId)); - writeAt(buf801, 3, pad(teamIdString801, 4, 'right')); + writeAt(buffer801, 3, pad(teamIdString801, 4, 'right')); if (record.nickname !== undefined) { - writeAt(buf801, 7, pad(record.nickname.slice(0, 5), 5, 'left')); + writeAt(buffer801, 7, pad(record.nickname.slice(0, 5), 5, 'left')); } - writeAt(buf801, 12, pad(String(record.matchPoints), 4, 'right')); - writeAt(buf801, 16, pad(record.gamePoints.toFixed(1), 6, 'right')); + writeAt(buffer801, 12, pad(String(record.matchPoints), 4, 'right')); + writeAt(buffer801, 16, pad(record.gamePoints.toFixed(1), 6, 'right')); for (const r of record.results as TeamRoundResult801[]) { const pos = 22 + (r.round - 1) * 16; - while (buf801.length < pos + 16) { - buf801.push(' '); + while (buffer801.length < pos + 16) { + buffer801.push(' '); } if (r.type === undefined) { const oppString = r.opponentId === null ? '' : String(Number(r.opponentId)); - writeAt(buf801, pos, ` ${pad(oppString, 3, 'right')} ${r.raw}`); + writeAt(buffer801, pos, ` ${pad(oppString, 3, 'right')} ${r.raw}`); } else { // Bye: write marker centered in block const BYE_MARKER_801: Record = { @@ -658,44 +669,52 @@ export default function stringify( ZPB: 'ZZZZ', }; const marker = BYE_MARKER_801[r.type] ?? 'ZZZZ'; - writeAt(buf801, pos + 5, ` ${marker} `); + writeAt(buffer801, pos + 5, ` ${marker} `); } } - lines.push(buf801.join('').trimEnd()); + lines.push(buffer801.join('').trimEnd()); } else { // 802 - const buf802: string[] = Array.from({ length: 28 }, () => ' '); - writeAt(buf802, 0, '802'); + const buffer802: string[] = Array.from({ length: 28 }, () => ' '); + writeAt(buffer802, 0, '802'); const teamIdString802 = String(Number(record.teamId)); - writeAt(buf802, 4, pad(teamIdString802, 3, 'right')); + writeAt(buffer802, 4, pad(teamIdString802, 3, 'right')); if (record.nickname !== undefined) { - writeAt(buf802, 8, pad(record.nickname.slice(0, 5), 5, 'left')); + writeAt(buffer802, 8, pad(record.nickname.slice(0, 5), 5, 'left')); } - writeAt(buf802, 14, pad(record.matchPoints.toFixed(1), 6, 'right')); - writeAt(buf802, 21, pad(record.gamePoints.toFixed(1), 6, 'right')); + writeAt(buffer802, 14, pad(record.matchPoints.toFixed(1), 6, 'right')); + writeAt(buffer802, 21, pad(record.gamePoints.toFixed(1), 6, 'right')); for (const r of record.results as TeamRoundResult802[]) { const pos = 28 + (r.round - 1) * 13; - while (buf802.length < pos + 13) { - buf802.push(' '); + while (buffer802.length < pos + 13) { + buffer802.push(' '); } if (r.type === undefined) { const oppString = r.opponentId === null ? '' : String(Number(r.opponentId)); - writeAt(buf802, pos, pad(oppString, 3, 'right')); + writeAt(buffer802, pos, pad(oppString, 3, 'right')); if (r.color !== undefined) { - buf802[pos + 4] = r.color; + buffer802[pos + 4] = r.color; } - writeAt(buf802, pos + 6, pad(r.gamePoints.toFixed(1), 4, 'right')); + writeAt( + buffer802, + pos + 6, + pad(r.gamePoints.toFixed(1), 4, 'right'), + ); if (r.forfeit === true) { - buf802[pos + 10] = 'f'; + buffer802[pos + 10] = 'f'; } } else { // Bye type - writeAt(buf802, pos, r.type); - writeAt(buf802, pos + 6, pad(r.gamePoints.toFixed(1), 4, 'right')); + writeAt(buffer802, pos, r.type); + writeAt( + buffer802, + pos + 6, + pad(r.gamePoints.toFixed(1), 4, 'right'), + ); } } - lines.push(buf802.join('').trimEnd()); + lines.push(buffer802.join('').trimEnd()); } } }