@speleotica/frcsdata 5.0.0-beta.1 → 5.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/ParseIssue.js +4 -4
  2. package/ParseIssue.js.map +1 -1
  3. package/SourceLoc.js +5 -5
  4. package/SourceLoc.js.map +1 -1
  5. package/chunksToLines.js +29 -131
  6. package/chunksToLines.js.map +1 -1
  7. package/cli/check-survey-correspondence.d.ts +2 -0
  8. package/cli/check-survey-correspondence.d.ts.map +1 -0
  9. package/cli/check-survey-correspondence.js +44 -0
  10. package/cli/check-survey-correspondence.js.map +1 -0
  11. package/cli/check-survey.d.ts.map +1 -1
  12. package/cli/check-survey.js +14 -75
  13. package/cli/check-survey.js.map +1 -1
  14. package/cli/parse-survey.js +4 -26
  15. package/cli/parse-survey.js.map +1 -1
  16. package/cli/summarize-survey.d.ts +2 -0
  17. package/cli/summarize-survey.d.ts.map +1 -0
  18. package/cli/summarize-survey.js +33 -0
  19. package/cli/summarize-survey.js.map +1 -0
  20. package/cli.js +61 -72
  21. package/cli.js.map +1 -1
  22. package/formatFrcsTripSummaryFile.d.ts +3 -0
  23. package/formatFrcsTripSummaryFile.d.ts.map +1 -0
  24. package/formatFrcsTripSummaryFile.js +33 -0
  25. package/formatFrcsTripSummaryFile.js.map +1 -0
  26. package/formatIssues.d.ts +10 -0
  27. package/formatIssues.d.ts.map +1 -0
  28. package/formatIssues.js +52 -0
  29. package/formatIssues.js.map +1 -0
  30. package/index.js +13 -13
  31. package/node/index.d.ts +3 -1
  32. package/node/index.d.ts.map +1 -1
  33. package/node/index.js +5 -19
  34. package/node/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/parseFrcsPlotFile.js +112 -245
  37. package/parseFrcsPlotFile.js.map +1 -1
  38. package/parseFrcsTripSummaryFile.d.ts +3 -1
  39. package/parseFrcsTripSummaryFile.d.ts.map +1 -1
  40. package/parseFrcsTripSummaryFile.js +53 -119
  41. package/parseFrcsTripSummaryFile.js.map +1 -1
  42. package/src/cli/check-survey-correspondence.ts +49 -0
  43. package/src/cli/check-survey.ts +8 -69
  44. package/src/cli/summarize-survey.ts +28 -0
  45. package/src/cli.ts +33 -0
  46. package/src/formatFrcsTripSummaryFile.ts +45 -0
  47. package/src/formatIssues.ts +97 -0
  48. package/src/parseFrcsTripSummaryFile.ts +8 -2
  49. package/src/survey/normalizeTeamMemberName.ts +3 -6
  50. package/src/survey/parseFrcsSurveyFile.ts +3 -17
  51. package/src/survey/summarizeSurvey.ts +51 -0
  52. package/src/unwrapInvalid.ts +3 -0
  53. package/string/index.d.ts +3 -1
  54. package/string/index.d.ts.map +1 -1
  55. package/string/index.js +7 -41
  56. package/string/index.js.map +1 -1
  57. package/survey/FrcsSurveyFile.js +1 -1
  58. package/survey/FrcsSurveyFile.js.map +1 -1
  59. package/survey/ZodFrcsSurveyFileJson.js +84 -86
  60. package/survey/ZodFrcsSurveyFileJson.js.map +1 -1
  61. package/survey/ZodFrcsSurveyFileToJson.js +78 -88
  62. package/survey/ZodFrcsSurveyFileToJson.js.map +1 -1
  63. package/survey/formatFrcsShot.js +45 -43
  64. package/survey/formatFrcsShot.js.map +1 -1
  65. package/survey/formatFrcsSurveyFile.js +52 -130
  66. package/survey/formatFrcsSurveyFile.js.map +1 -1
  67. package/survey/getColumnRanges.js +11 -19
  68. package/survey/getColumnRanges.js.map +1 -1
  69. package/survey/normalizeTeamMemberName.d.ts.map +1 -1
  70. package/survey/normalizeTeamMemberName.js +1 -5
  71. package/survey/normalizeTeamMemberName.js.map +1 -1
  72. package/survey/parseFrcsSurveyFile.d.ts.map +1 -1
  73. package/survey/parseFrcsSurveyFile.js +558 -750
  74. package/survey/parseFrcsSurveyFile.js.map +1 -1
  75. package/survey/parsers.js +20 -20
  76. package/survey/parsers.js.map +1 -1
  77. package/survey/summarizeSurvey.d.ts +6 -0
  78. package/survey/summarizeSurvey.d.ts.map +1 -0
  79. package/survey/summarizeSurvey.js +58 -0
  80. package/survey/summarizeSurvey.js.map +1 -0
  81. package/underlineSource.js +9 -17
  82. package/underlineSource.js.map +1 -1
  83. package/unwrapInvalid.d.ts +4 -0
  84. package/unwrapInvalid.d.ts.map +1 -0
  85. package/unwrapInvalid.js +10 -0
  86. package/unwrapInvalid.js.map +1 -0
  87. package/web/index.js +56 -116
  88. package/web/index.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parseFrcsTripSummaryFile.js","names":["_unitized","require","_asyncIterator","r","n","t","o","e","Symbol","asyncIterator","iterator","call","AsyncFromSyncIterator","TypeError","AsyncFromSyncIteratorContinuation","Object","Promise","reject","done","resolve","value","then","s","next","prototype","apply","arguments","_return","_throw","tripSummaryRegex","parseFrcsTripSummaryFile","_x","_x2","_parseFrcsTripSummaryFile","_asyncToGenerator2","_regenerator","mark","_callee","file","lines","errors","tripSummaries","tripStartLine","lineNumber","team","shots","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_step","line","match","tripNumber","tripIndex","year","date","totalLength","numShots","name","excludedLength","numExcludedShots","_team","_shots","trimmed","wrap","_callee$","_context","prev","sent","exec","parseInt","Date","Unitize","feet","parseFloat","trim","abrupt","push","_toConsumableArray2","split","t0","finish","stop","module","exports","default"],"sources":["src/parseFrcsTripSummaryFile.ts"],"sourcesContent":["import { FrcsTripSummary } from './FrcsTripSummary'\nimport { FrcsTripSummaryFile } from './FrcsTripSummaryFile'\nimport { SegmentParseError } from 'parse-segment'\nimport { Unitize } from '@speleotica/unitized'\n\nconst tripSummaryRegex =\n /^\\s*(\\d+)\\s+(\\d{1,2})\\/(\\s\\d|\\d\\d)\\/(\\d{2,4})\\s+(\\d+(?:\\.\\d*)?)\\s+(\\d+)\\s+(\\S.*)EXCLUDED:\\s*(\\d+(?:\\.\\d{2})?)\\s*(\\d+)/\n/**\n * Parses data from a STAT_sum.txt file. Here is an excerpt of the format:\n<pre> 1 2/15/81 258.60 17 ENTRANCE DROPS, JOE'S \"I LOVE MY WIFE TRAVERSE\", TRICKY TRAVERSE EXCLUDED: 0.00 0\n Peter Quick Keith Ortiz\n A1 AD1-AD3 AE1 AE1 SIDE\n AE9 SIDE AE10-AE9 AE13 SIDE AE15 SIDE\n AE20-AE11\n\n 3 3/ 6/81 2371.20 61 DOUG'S DEMISE (50 FT DROP), CHRIS CROSS, CRAWL ABOVE DROP EXCLUDED: 0.00 0\n Peter Quick Chris Gerace Phil Oden Chip Hopper\n A13 SIDE B1-B5 B2 SIDE B3 SIDE\n B6-B18 B17 SIDE B19-B38 B32 SIDE\n BS1-BS5 C1-C18 </pre>\n */\nexport default async function parseFrcsTripSummaryFile(\n file: string,\n lines: AsyncIterable<string>\n): Promise<FrcsTripSummaryFile> {\n const errors: Array<SegmentParseError> = []\n const tripSummaries: Array<FrcsTripSummary | undefined> = []\n\n let tripStartLine = -2\n let lineNumber = 0\n\n let team: Array<string> = []\n let shots: Array<string> = []\n\n for await (const line of lines) {\n lineNumber++\n\n const match = tripSummaryRegex.exec(line)\n if (match) {\n tripStartLine = lineNumber\n const tripNumber = parseInt(match[1])\n const tripIndex = tripNumber - 1\n let year = parseInt(match[4])\n if (year < 1000) year += 1900\n const date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]))\n const totalLength = Unitize.feet(parseFloat(match[5]))\n const numShots = parseInt(match[6])\n const name = match[7].trim()\n const excludedLength = Unitize.feet(parseFloat(match[8]))\n const numExcludedShots = parseInt(match[9])\n team = []\n shots = []\n tripSummaries[tripIndex] = {\n tripNumber,\n tripIndex,\n date,\n totalLength,\n numShots,\n name,\n excludedLength,\n numExcludedShots,\n team,\n shots,\n }\n continue\n }\n if (lineNumber === tripStartLine + 1) {\n team.push(...line.trim().split(/\\s\\s+|\\t+/g))\n } else {\n const trimmed = line.trim()\n if (trimmed) shots.push(...trimmed.split(/\\s\\s+|\\t+/))\n }\n }\n\n return { errors, tripSummaries }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAA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AAA;QAAA;UAAAkB,QAAA,CAAAC,IAAA;UAAA,KAAArB,iBAAA;YAAAoB,QAAA,CAAA5C,IAAA;YAAA;UAAA;UAAA,MAAAyB,cAAA;QAAA;UAAA,OAAAmB,QAAA,CAAAe,MAAA;QAAA;UAAA,OAAAf,QAAA,CAAAe,MAAA;QAAA;UAAA,OAAAf,QAAA,CAAAU,MAAA,WAGI;YAAErC,MAAM,EAANA,MAAM;YAAEC,aAAa,EAAbA;UAAc,CAAC;QAAA;QAAA;UAAA,OAAA0B,QAAA,CAAAgB,IAAA;MAAA;IAAA,GAAA9C,OAAA;EAAA,CACjC;EAAA,OAAAJ,yBAAA,CAAAR,KAAA,OAAAC,SAAA;AAAA;AAAA0D,MAAA,CAAAC,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"parseFrcsTripSummaryFile.js","names":["_unitized","require","tripSummaryRegex","parseFrcsTripSummaryFile","file","lines","indexBy","errors","tripSummaries","tripStartLine","lineNumber","team","shots","line","match","exec","tripNumber","parseInt","tripIndex","length","year","date","Date","totalLength","Unitize","feet","parseFloat","numShots","name","trim","excludedLength","numExcludedShots","push","split","trimmed","module","exports","default"],"sources":["src/parseFrcsTripSummaryFile.ts"],"sourcesContent":["import { FrcsTripSummary } from './FrcsTripSummary'\nimport { FrcsTripSummaryFile } from './FrcsTripSummaryFile'\nimport { SegmentParseError } from 'parse-segment'\nimport { Unitize } from '@speleotica/unitized'\n\nconst tripSummaryRegex =\n /^\\s*(\\d+)\\s+(\\d{1,2})\\/(\\s\\d|\\d\\d)\\/(\\d{2,4})\\s+(\\d+(?:\\.\\d*)?)\\s+(\\d+)\\s+(\\S.*)EXCLUDED:\\s*(\\d+(?:\\.\\d{2})?)\\s*(\\d+)/\n/**\n * Parses data from a STAT_sum.txt file. Here is an excerpt of the format:\n<pre> 1 2/15/81 258.60 17 ENTRANCE DROPS, JOE'S \"I LOVE MY WIFE TRAVERSE\", TRICKY TRAVERSE EXCLUDED: 0.00 0\n Peter Quick Keith Ortiz\n A1 AD1-AD3 AE1 AE1 SIDE\n AE9 SIDE AE10-AE9 AE13 SIDE AE15 SIDE\n AE20-AE11\n\n 3 3/ 6/81 2371.20 61 DOUG'S DEMISE (50 FT DROP), CHRIS CROSS, CRAWL ABOVE DROP EXCLUDED: 0.00 0\n Peter Quick Chris Gerace Phil Oden Chip Hopper\n A13 SIDE B1-B5 B2 SIDE B3 SIDE\n B6-B18 B17 SIDE B19-B38 B32 SIDE\n BS1-BS5 C1-C18 </pre>\n */\nexport default async function parseFrcsTripSummaryFile(\n file: string,\n lines: AsyncIterable<string>,\n {\n indexBy = 'tripNumber',\n }: {\n indexBy?: 'tripNumber' | 'occurrence'\n } = {}\n): Promise<FrcsTripSummaryFile> {\n const errors: Array<SegmentParseError> = []\n const tripSummaries: Array<FrcsTripSummary | undefined> = []\n\n let tripStartLine = -2\n let lineNumber = 0\n\n let team: Array<string> = []\n let shots: Array<string> = []\n\n for await (const line of lines) {\n lineNumber++\n\n const match = tripSummaryRegex.exec(line)\n if (match) {\n tripStartLine = lineNumber\n const tripNumber = parseInt(match[1])\n const tripIndex =\n indexBy === 'tripNumber' ? tripNumber - 1 : tripSummaries.length\n let year = parseInt(match[4])\n if (year < 1000) year += 1900\n const date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]))\n const totalLength = Unitize.feet(parseFloat(match[5]))\n const numShots = parseInt(match[6])\n const name = match[7].trim()\n const excludedLength = Unitize.feet(parseFloat(match[8]))\n const numExcludedShots = parseInt(match[9])\n team = []\n shots = []\n tripSummaries[tripIndex] = {\n tripNumber,\n tripIndex,\n date,\n totalLength,\n numShots,\n name,\n excludedLength,\n numExcludedShots,\n team,\n shots,\n }\n continue\n }\n if (lineNumber === tripStartLine + 1) {\n team.push(...line.trim().split(/\\s\\s+|\\t+/g))\n } else {\n const trimmed = line.trim()\n if (trimmed) shots.push(...trimmed.split(/\\s\\s+|\\t+/))\n }\n }\n\n return { errors, tripSummaries }\n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,QAAQ,GAAGV,QAAQ,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;MACnC,MAAMc,IAAI,GAAGd,KAAK,CAAC,CAAC,CAAC,CAACe,IAAI,CAAC,CAAC;MAC5B,MAAMC,cAAc,GAAGN,iBAAO,CAACC,IAAI,CAACC,UAAU,CAACZ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;MACzD,MAAMiB,gBAAgB,GAAGd,QAAQ,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;MAC3CH,IAAI,GAAG,EAAE;MACTC,KAAK,GAAG,EAAE;MACVJ,aAAa,CAACU,SAAS,CAAC,GAAG;QACzBF,UAAU;QACVE,SAAS;QACTG,IAAI;QACJE,WAAW;QACXI,QAAQ;QACRC,IAAI;QACJE,cAAc;QACdC,gBAAgB;QAChBpB,IAAI;QACJC;MACF,CAAC;MACD;IACF;IACA,IAAIF,UAAU,KAAKD,aAAa,GAAG,CAAC,EAAE;MACpCE,IAAI,CAACqB,IAAI,CAAC,GAAGnB,IAAI,CAACgB,IAAI,CAAC,CAAC,CAACI,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC,MAAM;MACL,MAAMC,OAAO,GAAGrB,IAAI,CAACgB,IAAI,CAAC,CAAC;MAC3B,IAAIK,OAAO,EAAEtB,KAAK,CAACoB,IAAI,CAAC,GAAGE,OAAO,CAACD,KAAK,CAAC,WAAW,CAAC,CAAC;IACxD;EACF;EAEA,OAAO;IAAE1B,MAAM;IAAEC;EAAc,CAAC;AAClC;AAAC2B,MAAA,CAAAC,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ /* eslint-disable no-console */
2
+ import chalk from 'chalk'
3
+ import { parseFrcsSurveyFile } from '../string/index'
4
+ import fs from 'fs/promises'
5
+ import { summarizeSurvey } from '../survey/summarizeSurvey'
6
+ import { parseFrcsTripSummaryFile } from '../node/index.js'
7
+ import { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile.js'
8
+ import { isDeepStrictEqual } from 'util'
9
+
10
+ export async function checkSurveyCorrespondence(
11
+ surveyFile: string,
12
+ summaryFile: string
13
+ ) {
14
+ const source = await fs.readFile(surveyFile, 'utf8')
15
+ const parsedSurvey = await parseFrcsSurveyFile(surveyFile, source)
16
+ const parsedSummaries = (
17
+ await parseFrcsTripSummaryFile(summaryFile, { indexBy: 'occurrence' })
18
+ ).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))
19
+ const convertedSummaries = summarizeSurvey(parsedSurvey, {
20
+ ignoreVerticalOfHShots: true,
21
+ }).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))
22
+
23
+ let errored = false
24
+
25
+ for (
26
+ let i = 0;
27
+ i < Math.max(parsedSummaries.length, convertedSummaries.length);
28
+ i++
29
+ ) {
30
+ const parsed = parsedSummaries[i]
31
+ const converted = convertedSummaries[i]
32
+
33
+ const parsedLines = [
34
+ ...formatFrcsTripSummaryFile({ tripSummaries: [parsed] }),
35
+ ].slice(0, 2)
36
+ const convertedLines = [
37
+ ...formatFrcsTripSummaryFile({ tripSummaries: [converted] }),
38
+ ].slice(0, 2)
39
+
40
+ if (!isDeepStrictEqual(parsedLines, convertedLines)) {
41
+ errored = true
42
+ console.log(
43
+ convertedLines.map((line) => chalk.green('+' + line)).join('\n')
44
+ )
45
+ console.log(parsedLines.map((line) => chalk.red('-' + line)).join('\n'))
46
+ }
47
+ }
48
+ process.exit(errored ? 1 : 0)
49
+ }
@@ -1,83 +1,22 @@
1
1
  /* eslint-disable no-console */
2
2
  import fs from 'fs/promises'
3
3
  import parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'
4
- import { underlineSource } from '../underlineSource.js'
5
4
  import chalk from 'chalk'
5
+ import { formatIssues } from '../formatIssues.js'
6
6
 
7
7
  export async function checkSurvey(file: string) {
8
8
  const source = await fs.readFile(file, 'utf8')
9
9
  const parsed = await parseFrcsSurveyFile(file, [source])
10
10
 
11
11
  const issues = parsed.issues || []
12
- for (const issue of issues) {
13
- const { type, loc, message } = issue
14
- const style = type === 'error' ? chalk.red : chalk.yellow
15
- console.log(
16
- `${style(
17
- `${
18
- type === 'error' ? chalk.red('✘') : chalk.yellow('⚠')
19
- } ${`${type[0].toUpperCase()}${type.substring(1)}:`.padEnd(
20
- 8
21
- )} ${message?.padEnd(40)}`
22
- )} (${file}:${loc?.start?.line}:${loc?.start?.column})`
23
- )
24
- if (loc) {
25
- console.log(underlineSource(source, loc, { underlineStyle: style }))
26
- }
27
- }
28
-
29
- const errorCount = issues.reduce(
30
- (count, i) => (i.type === 'error' ? count + 1 : count),
31
- 0
32
- )
33
- const warningCount = issues.reduce(
34
- (count, i) => (i.type === 'warning' ? count + 1 : count),
35
- 0
36
- )
37
- const trips = 'INVALID' in parsed ? parsed.INVALID.trips : parsed.trips
38
- const tripCount = trips.length
39
- const shotCount = trips.reduce(
40
- (count, trip) =>
41
- count +
42
- ('INVALID' in trip ? trip.INVALID.shots.length : trip.shots.length),
43
- 0
44
- )
45
-
46
- const fmtErrorCount = `✘ ${errorCount}`
47
- const fmtWarningCount = `⚠ ${warningCount}`
48
- const fmtTripCount = `${tripCount}`
49
- const fmtShotCount = `${shotCount}`
50
-
51
- const countWidth = Math.max(
52
- fmtErrorCount.length,
53
- fmtWarningCount.length,
54
- fmtTripCount.length,
55
- fmtShotCount.length
56
- )
57
-
58
- if (errorCount) {
59
- console.log(
60
- chalk.red(
61
- `${fmtErrorCount.padStart(countWidth)} error${
62
- errorCount === 1 ? '' : 's'
63
- }`
64
- )
65
- )
66
- }
67
- if (warningCount) {
68
- console.log(
69
- chalk.yellow(
70
- `${fmtWarningCount.padStart(countWidth)} warning${
71
- warningCount === 1 ? '' : 's'
72
- }`
73
- )
74
- )
75
- }
76
- console.log(
77
- `${fmtTripCount.padStart(countWidth)} trip${tripCount === 1 ? '' : 's'}`
78
- )
79
12
  console.log(
80
- `${fmtShotCount.padStart(countWidth)} shot${shotCount === 1 ? '' : 's'}`
13
+ formatIssues({
14
+ file,
15
+ source,
16
+ parsed,
17
+ errorStyle: chalk.red,
18
+ warningStyle: chalk.yellow,
19
+ })
81
20
  )
82
21
 
83
22
  process.exit(issues.some((i) => i.type === 'error') ? 1 : 0)
@@ -0,0 +1,28 @@
1
+ /* eslint-disable no-console */
2
+ import chalk from 'chalk'
3
+ import { formatIssues } from '../formatIssues'
4
+ import { parseFrcsSurveyFile } from '../string/index'
5
+ import fs from 'fs/promises'
6
+ import { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile'
7
+ import { summarizeSurvey as baseSummarizeSurvey } from '../survey/summarizeSurvey'
8
+
9
+ export async function summarizeSurvey(file: string) {
10
+ const source = await fs.readFile(file, 'utf8')
11
+ const parsed = await parseFrcsSurveyFile(file, source)
12
+ if ('INVALID' in parsed) {
13
+ console.log(
14
+ formatIssues({
15
+ file,
16
+ source,
17
+ parsed,
18
+ errorStyle: chalk.red,
19
+ warningStyle: chalk.yellow,
20
+ })
21
+ )
22
+ process.exit(1)
23
+ }
24
+
25
+ for (const line of formatFrcsTripSummaryFile(baseSummarizeSurvey(parsed))) {
26
+ console.log(line)
27
+ }
28
+ }
package/src/cli.ts CHANGED
@@ -27,4 +27,37 @@ void yargs(process.argv.slice(2))
27
27
  await parseSurvey(file)
28
28
  },
29
29
  })
30
+ .command({
31
+ command: 'summarize-survey <file>',
32
+ describe: 'parse survey file and output trip summaries',
33
+ builder: (yargs) =>
34
+ yargs.positional('file', {
35
+ type: 'string',
36
+ demandOption: true,
37
+ }),
38
+ handler: async ({ file }) => {
39
+ const { summarizeSurvey } = await import('./cli/summarize-survey')
40
+ await summarizeSurvey(file)
41
+ },
42
+ })
43
+ .command({
44
+ command: 'check-survey-correspondence <surveyFile> <summaryFile>',
45
+ describe: 'parse survey file and output trip summaries',
46
+ builder: (yargs) =>
47
+ yargs
48
+ .positional('surveyFile', {
49
+ type: 'string',
50
+ demandOption: true,
51
+ })
52
+ .positional('summaryFile', {
53
+ type: 'string',
54
+ demandOption: true,
55
+ }),
56
+ handler: async ({ surveyFile, summaryFile }) => {
57
+ const { checkSurveyCorrespondence } = await import(
58
+ './cli/check-survey-correspondence'
59
+ )
60
+ await checkSurveyCorrespondence(surveyFile, summaryFile)
61
+ },
62
+ })
30
63
  .demandCommand().argv
@@ -0,0 +1,45 @@
1
+ import { Length } from '@speleotica/unitized'
2
+ import { FrcsTripSummaryFile } from './FrcsTripSummaryFile.js'
3
+
4
+ const nameLength = 78
5
+
6
+ export function* formatFrcsTripSummaryFile(
7
+ file: FrcsTripSummaryFile
8
+ ): Iterable<string> {
9
+ for (const summary of file.tripSummaries) {
10
+ if (!summary) continue
11
+ const {
12
+ tripNumber,
13
+ date,
14
+ totalLength,
15
+ numShots,
16
+ name,
17
+ excludedLength,
18
+ numExcludedShots,
19
+ team,
20
+ shots,
21
+ } = summary
22
+ const month = (date.getMonth() + 1).toFixed()
23
+ const day = date.getDate().toFixed()
24
+ const year = date.getFullYear().toFixed()
25
+ yield `${tripNumber.toFixed().padStart(3)} ${month.padStart(
26
+ 2
27
+ )}/${day.padStart(2)}/${year.padStart(4)}${totalLength
28
+ .get(Length.feet)
29
+ .toFixed(2)
30
+ .padStart(10)}${numShots.toFixed().padStart(5)} ${name
31
+ .slice(0, nameLength)
32
+ .padEnd(nameLength)} EXCLUDED:${excludedLength
33
+ .get(Length.feet)
34
+ .toFixed(2)
35
+ .padStart(7)}${numExcludedShots.toFixed().padStart(3)}`
36
+ yield ' '.repeat(tripNumber >= 1000 ? 34 : 33) + team.join(' ')
37
+ for (let i = 0; i < shots.length; i += 4) {
38
+ yield ' '.repeat(tripNumber >= 1000 ? 36 : 35) +
39
+ shots
40
+ .slice(i, i + 4)
41
+ .map((s) => s.padEnd(14))
42
+ .join('')
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,97 @@
1
+ import { FrcsSurveyFile, InvalidFrcsSurveyFile } from './survey/FrcsSurveyFile'
2
+ import {
3
+ FrcsSurveyFileJson,
4
+ InvalidFrcsSurveyFileJson,
5
+ } from './survey/FrcsSurveyFileJson.js'
6
+ import { underlineSource } from './underlineSource'
7
+ import { unwrapInvalid } from './unwrapInvalid.js'
8
+
9
+ export function formatIssues({
10
+ parsed,
11
+ source,
12
+ file,
13
+ errorStyle = (s) => s,
14
+ warningStyle = (s) => s,
15
+ }: {
16
+ parsed:
17
+ | FrcsSurveyFile
18
+ | InvalidFrcsSurveyFile
19
+ | FrcsSurveyFileJson
20
+ | InvalidFrcsSurveyFileJson
21
+ source: string
22
+ file: string
23
+ errorStyle?: (s: string) => string
24
+ warningStyle?: (s: string) => string
25
+ }) {
26
+ const issues = parsed.issues || []
27
+ const lines: string[] = []
28
+ for (const issue of issues) {
29
+ const { type, loc, message } = issue
30
+ const style = type === 'error' ? errorStyle : warningStyle
31
+ lines.push(
32
+ `${style(
33
+ `${
34
+ type === 'error' ? errorStyle('✘') : warningStyle('⚠')
35
+ } ${`${type[0].toUpperCase()}${type.substring(1)}:`.padEnd(
36
+ 8
37
+ )} ${message?.padEnd(40)}`
38
+ )} (${file}:${loc?.start?.line}:${loc?.start?.column})`
39
+ )
40
+ if (loc) {
41
+ lines.push(underlineSource(source, loc, { underlineStyle: style }))
42
+ }
43
+ }
44
+
45
+ const errorCount = issues.reduce(
46
+ (count, i) => (i.type === 'error' ? count + 1 : count),
47
+ 0
48
+ )
49
+ const warningCount = issues.reduce(
50
+ (count, i) => (i.type === 'warning' ? count + 1 : count),
51
+ 0
52
+ )
53
+ const trips = unwrapInvalid(parsed).trips
54
+ const tripCount = trips.length
55
+ const shotCount = trips.reduce(
56
+ (count, trip) => count + unwrapInvalid(trip).shots.length,
57
+ 0
58
+ )
59
+
60
+ const fmtErrorCount = `✘ ${errorCount}`
61
+ const fmtWarningCount = `⚠ ${warningCount}`
62
+ const fmtTripCount = `${tripCount}`
63
+ const fmtShotCount = `${shotCount}`
64
+
65
+ const countWidth = Math.max(
66
+ fmtErrorCount.length,
67
+ fmtWarningCount.length,
68
+ fmtTripCount.length,
69
+ fmtShotCount.length
70
+ )
71
+
72
+ if (errorCount) {
73
+ lines.push(
74
+ errorStyle(
75
+ `${fmtErrorCount.padStart(countWidth)} error${
76
+ errorCount === 1 ? '' : 's'
77
+ }`
78
+ )
79
+ )
80
+ }
81
+ if (warningCount) {
82
+ lines.push(
83
+ warningStyle(
84
+ `${fmtWarningCount.padStart(countWidth)} warning${
85
+ warningCount === 1 ? '' : 's'
86
+ }`
87
+ )
88
+ )
89
+ }
90
+ lines.push(
91
+ `${fmtTripCount.padStart(countWidth)} trip${tripCount === 1 ? '' : 's'}`
92
+ )
93
+ lines.push(
94
+ `${fmtShotCount.padStart(countWidth)} shot${shotCount === 1 ? '' : 's'}`
95
+ )
96
+ return lines.join('\n')
97
+ }
@@ -21,7 +21,12 @@ const tripSummaryRegex =
21
21
  */
22
22
  export default async function parseFrcsTripSummaryFile(
23
23
  file: string,
24
- lines: AsyncIterable<string>
24
+ lines: AsyncIterable<string>,
25
+ {
26
+ indexBy = 'tripNumber',
27
+ }: {
28
+ indexBy?: 'tripNumber' | 'occurrence'
29
+ } = {}
25
30
  ): Promise<FrcsTripSummaryFile> {
26
31
  const errors: Array<SegmentParseError> = []
27
32
  const tripSummaries: Array<FrcsTripSummary | undefined> = []
@@ -39,7 +44,8 @@ export default async function parseFrcsTripSummaryFile(
39
44
  if (match) {
40
45
  tripStartLine = lineNumber
41
46
  const tripNumber = parseInt(match[1])
42
- const tripIndex = tripNumber - 1
47
+ const tripIndex =
48
+ indexBy === 'tripNumber' ? tripNumber - 1 : tripSummaries.length
43
49
  let year = parseInt(match[4])
44
50
  if (year < 1000) year += 1900
45
51
  const date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]))
@@ -1,10 +1,7 @@
1
1
  export function normalizeTeamMemberName(name: string) {
2
- if (name.toUpperCase() === name) {
3
- name = name.replace(
4
- /(\S)(\S*)/g,
5
- (match, head, tail) => `${head}${tail.toLowerCase()}`
6
- )
7
- }
2
+ name = name.replace(/(\S)(\S*)/g, (match, head, tail) =>
3
+ match.toUpperCase() === match ? `${head}${tail.toLowerCase()}` : match
4
+ )
8
5
  name = name.replace(/_/g, ' ')
9
6
  return name
10
7
  }
@@ -33,6 +33,7 @@ import {
33
33
  parseAzimuth,
34
34
  } from './parsers'
35
35
  import { normalizeTeamMemberName } from './normalizeTeamMemberName'
36
+ import { unwrapInvalid } from '../unwrapInvalid'
36
37
 
37
38
  /**
38
39
  * Parses a raw cdata.fr survey file. These look like so:
@@ -202,7 +203,7 @@ export default async function parseFrcsSurveyFile(
202
203
  day = parseInt(dateMatch[11])
203
204
  year = parseInt(dateMatch[12])
204
205
  }
205
- tripDate = new Date(year < 70 ? year + 2000 : year, month - 1, day)
206
+ tripDate = new Date(year < 60 ? year + 2000 : year, month - 1, day)
206
207
  } else {
207
208
  addIssue(
208
209
  'warning',
@@ -566,18 +567,7 @@ export default async function parseFrcsSurveyFile(
566
567
 
567
568
  if (trip) trips.push(trip)
568
569
 
569
- trips
570
- .map((trip, index) => ({ trip: unwrapInvalid(trip), index }))
571
- .sort((a, b) => {
572
- const aDate = unwrapInvalid(a.trip.header).date
573
- const bDate = unwrapInvalid(b.trip.header).date
574
- return (
575
- (aDate != null && bDate != null
576
- ? aDate.getTime() - bDate.getTime()
577
- : 0) || a.index - b.index
578
- )
579
- })
580
- .forEach(({ trip }, index) => (trip.tripNumber = index + 1))
570
+ trips.forEach((trip, index) => (unwrapInvalid(trip).tripNumber = index + 1))
581
571
 
582
572
  if (
583
573
  !issues.some((i) => i.type === 'error') &&
@@ -856,7 +846,3 @@ export default async function parseFrcsSurveyFile(
856
846
  }
857
847
  }
858
848
  }
859
-
860
- function unwrapInvalid<T>(t: T): T extends { INVALID: infer I } ? I : T {
861
- return (t instanceof Object && 'INVALID' in t ? t.INVALID : t) as any
862
- }
@@ -0,0 +1,51 @@
1
+ import { Length, UnitizedNumber } from '@speleotica/unitized'
2
+ import { FrcsTripSummaryFile } from '../FrcsTripSummaryFile.js'
3
+ import { FrcsSurveyFile, InvalidFrcsSurveyFile } from './FrcsSurveyFile.js'
4
+ import { unwrapInvalid } from '../unwrapInvalid.js'
5
+
6
+ export function summarizeSurvey(
7
+ parsed: FrcsSurveyFile | InvalidFrcsSurveyFile,
8
+ options?: { ignoreVerticalOfHShots?: boolean }
9
+ ) {
10
+ const summary: FrcsTripSummaryFile = {
11
+ tripSummaries: [],
12
+ }
13
+ let tripIndex = 0
14
+ for (const trip of unwrapInvalid(parsed).trips) {
15
+ const { tripNumber, header, units, shots } = unwrapInvalid(trip)
16
+ const { name, date, team } = unwrapInvalid(header)
17
+ const distanceUnit = unwrapInvalid(units).distanceUnit || Length.feet
18
+ let totalLength = new UnitizedNumber(0, distanceUnit)
19
+ let excludedLength = new UnitizedNumber(0, distanceUnit)
20
+ let numExcludedShots = 0
21
+
22
+ for (const shot of unwrapInvalid(shots)) {
23
+ const { distance, horizontalDistance, excludeDistance } =
24
+ unwrapInvalid(shot)
25
+ const statDistance =
26
+ options?.ignoreVerticalOfHShots && horizontalDistance
27
+ ? horizontalDistance
28
+ : distance
29
+ if (statDistance) totalLength = totalLength.add(statDistance)
30
+ if (excludeDistance) {
31
+ numExcludedShots++
32
+ if (statDistance) excludedLength = excludedLength.add(statDistance)
33
+ }
34
+ }
35
+
36
+ summary.tripSummaries.push({
37
+ tripNumber: tripNumber ?? NaN,
38
+ tripIndex: tripIndex++,
39
+ date: date || new Date(NaN),
40
+ name: name || '',
41
+ team: team || [],
42
+ numShots: shots.length,
43
+ totalLength,
44
+ numExcludedShots,
45
+ excludedLength,
46
+ shots: [],
47
+ })
48
+ }
49
+
50
+ return summary
51
+ }
@@ -0,0 +1,3 @@
1
+ export function unwrapInvalid<T>(t: T): T extends { INVALID: infer I } ? I : T {
2
+ return (t instanceof Object && 'INVALID' in t ? t.INVALID : t) as any
3
+ }
package/string/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export declare const parseFrcsSurveyFile: (file: string, str: string, rest_0?: import("../survey/FrcsSurveyFile").ParseFrcsSurveyFileOptions | undefined) => Promise<import("..").FrcsSurveyFile | import("../survey/FrcsSurveyFile").InvalidFrcsSurveyFile>;
2
2
  export declare const parseFrcsPlotFile: (file: string, str: string) => Promise<import("..").FrcsPlotFile>;
3
- export declare const parseFrcsTripSummaryFile: (file: string, str: string) => Promise<import("..").FrcsTripSummaryFile>;
3
+ export declare const parseFrcsTripSummaryFile: (file: string, str: string, rest_0?: {
4
+ indexBy?: "tripNumber" | "occurrence";
5
+ } | undefined) => Promise<import("..").FrcsTripSummaryFile>;
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,mBAAmB,SAHvB,MAAM,OAAO,MAAM,wLAG8C,CAAA;AAC1E,eAAO,MAAM,iBAAiB,SAfrB,MAAM,OAAO,MAAM,uCAeyC,CAAA;AACrE,eAAO,MAAM,wBAAwB,SAhB5B,MAAM,OAAO,MAAM,8CAkB3B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,mBAAmB,SAHvB,MAAM,OAAO,MAAM,wLAG8C,CAAA;AAC1E,eAAO,MAAM,iBAAiB,SAfrB,MAAM,OAAO,MAAM,uCAeyC,CAAA;AACrE,eAAO,MAAM,wBAAwB,SAhB5B,MAAM,OAAO,MAAM;;2DAkB3B,CAAA"}
package/string/index.js CHANGED
@@ -5,49 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.parseFrcsTripSummaryFile = exports.parseFrcsSurveyFile = exports.parseFrcsPlotFile = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
10
- var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
11
- var _asyncGeneratorDelegate2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncGeneratorDelegate"));
12
8
  var _parseFrcsSurveyFile2 = _interopRequireDefault(require("../survey/parseFrcsSurveyFile.js"));
13
9
  var _parseFrcsPlotFile2 = _interopRequireDefault(require("../parseFrcsPlotFile.js"));
14
10
  var _parseFrcsTripSummaryFile2 = _interopRequireDefault(require("../parseFrcsTripSummaryFile.js"));
15
- function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
16
- function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
17
- function linesOf(_x) {
18
- return _linesOf.apply(this, arguments);
11
+ async function* linesOf(s) {
12
+ yield* s.split(/\r\n?|\n/gm);
19
13
  }
20
- function _linesOf() {
21
- _linesOf = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(s) {
22
- return _regenerator["default"].wrap(function _callee$(_context) {
23
- while (1) switch (_context.prev = _context.next) {
24
- case 0:
25
- return _context.delegateYield((0, _asyncGeneratorDelegate2["default"])(_asyncIterator(s.split(/\r\n?|\n/gm)), _awaitAsyncGenerator2["default"]), "t0", 1);
26
- case 1:
27
- case "end":
28
- return _context.stop();
29
- }
30
- }, _callee);
31
- }));
32
- return _linesOf.apply(this, arguments);
33
- }
34
- var convertLineBased = function convertLineBased(fn) {
35
- return function (file, str) {
36
- for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
37
- rest[_key - 2] = arguments[_key];
38
- }
39
- return fn.apply(void 0, [file, linesOf(str)].concat(rest));
40
- };
41
- };
42
- var convertChunkBased = function convertChunkBased(fn) {
43
- return function (file, str) {
44
- for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
45
- rest[_key2 - 2] = arguments[_key2];
46
- }
47
- return fn.apply(void 0, [file, [str]].concat(rest));
48
- };
49
- };
50
- var parseFrcsSurveyFile = exports.parseFrcsSurveyFile = convertChunkBased(_parseFrcsSurveyFile2["default"]);
51
- var parseFrcsPlotFile = exports.parseFrcsPlotFile = convertLineBased(_parseFrcsPlotFile2["default"]);
52
- var parseFrcsTripSummaryFile = exports.parseFrcsTripSummaryFile = convertLineBased(_parseFrcsTripSummaryFile2["default"]);
14
+ const convertLineBased = fn => (file, str, ...rest) => fn(file, linesOf(str), ...rest);
15
+ const convertChunkBased = fn => (file, str, ...rest) => fn(file, [str], ...rest);
16
+ const parseFrcsSurveyFile = exports.parseFrcsSurveyFile = convertChunkBased(_parseFrcsSurveyFile2.default);
17
+ const parseFrcsPlotFile = exports.parseFrcsPlotFile = convertLineBased(_parseFrcsPlotFile2.default);
18
+ const parseFrcsTripSummaryFile = exports.parseFrcsTripSummaryFile = convertLineBased(_parseFrcsTripSummaryFile2.default);
53
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_parseFrcsSurveyFile2","_interopRequireDefault","require","_parseFrcsPlotFile2","_parseFrcsTripSummaryFile2","_asyncIterator","r","n","t","o","e","Symbol","asyncIterator","iterator","call","AsyncFromSyncIterator","TypeError","AsyncFromSyncIteratorContinuation","Object","Promise","reject","done","resolve","value","then","s","next","prototype","apply","arguments","_return","_throw","linesOf","_x","_linesOf","_wrapAsyncGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","delegateYield","_asyncGeneratorDelegate2","split","_awaitAsyncGenerator2","stop","convertLineBased","fn","file","str","_len","length","rest","Array","_key","concat","convertChunkBased","_len2","_key2","parseFrcsSurveyFile","exports","_parseFrcsSurveyFile","parseFrcsPlotFile","_parseFrcsPlotFile","parseFrcsTripSummaryFile","_parseFrcsTripSummaryFile"],"sources":["../../src/string/index.ts"],"sourcesContent":["import _parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport _parseFrcsPlotFile from '../parseFrcsPlotFile'\nimport _parseFrcsTripSummaryFile from '../parseFrcsTripSummaryFile'\n\nasync function* linesOf(s: string): AsyncIterable<string> {\n yield* s.split(/\\r\\n?|\\n/gm)\n}\nconst convertLineBased =\n <T, Rest extends any[]>(\n fn: (\n file: string,\n lines: AsyncIterable<string>,\n ...rest: Rest\n ) => Promise<T>\n ) =>\n (file: string, str: string, ...rest: Rest): Promise<T> =>\n fn(file, linesOf(str), ...rest)\n\nconst convertChunkBased =\n <T, Rest extends any[]>(\n fn: (\n file: string,\n lines: Iterable<string> | AsyncIterable<string>,\n ...rest: Rest\n ) => Promise<T>\n ) =>\n (file: string, str: string, ...rest: Rest): Promise<T> =>\n fn(file, [str], ...rest)\n\nexport const parseFrcsSurveyFile = convertChunkBased(_parseFrcsSurveyFile)\nexport const parseFrcsPlotFile = convertLineBased(_parseFrcsPlotFile)\nexport const parseFrcsTripSummaryFile = convertLineBased(\n _parseFrcsTripSummaryFile\n)\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,q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B,IAAI,EAAElB,OAAO,CAACmB,GAAG,CAAC,EAAAM,MAAA,CAAKH,IAAI,EAAC;EAAA;AAAA;AAEnC,IAAMI,iBAAiB,GACrB,SADIA,iBAAiBA,CAEnBT,EAIe;EAAA,OAEjB,UAACC,IAAY,EAAEC,GAAW;IAAA,SAAAQ,KAAA,GAAA9B,SAAA,CAAAwB,MAAA,EAAKC,IAAI,OAAAC,KAAA,CAAAI,KAAA,OAAAA,KAAA,WAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;MAAJN,IAAI,CAAAM,KAAA,QAAA/B,SAAA,CAAA+B,KAAA;IAAA;IAAA,OACjCX,EAAE,CAAArB,KAAA,UAACsB,IAAI,EAAE,CAACC,GAAG,CAAC,EAAAM,MAAA,CAAKH,IAAI,EAAC;EAAA;AAAA;AAErB,IAAMO,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGH,iBAAiB,CAACK,gCAAoB,CAAC;AACnE,IAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAGhB,gBAAgB,CAACiB,8BAAkB,CAAC;AAC9D,IAAMC,wBAAwB,GAAAJ,OAAA,CAAAI,wBAAA,GAAGlB,gBAAgB,CACtDmB,qCACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_parseFrcsSurveyFile2","_interopRequireDefault","require","_parseFrcsPlotFile2","_parseFrcsTripSummaryFile2","linesOf","s","split","convertLineBased","fn","file","str","rest","convertChunkBased","parseFrcsSurveyFile","exports","_parseFrcsSurveyFile","parseFrcsPlotFile","_parseFrcsPlotFile","parseFrcsTripSummaryFile","_parseFrcsTripSummaryFile"],"sources":["../../src/string/index.ts"],"sourcesContent":["import _parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport _parseFrcsPlotFile from '../parseFrcsPlotFile'\nimport _parseFrcsTripSummaryFile from '../parseFrcsTripSummaryFile'\n\nasync function* linesOf(s: string): AsyncIterable<string> {\n yield* s.split(/\\r\\n?|\\n/gm)\n}\nconst convertLineBased =\n <T, Rest extends any[]>(\n fn: (\n file: string,\n lines: AsyncIterable<string>,\n ...rest: Rest\n ) => Promise<T>\n ) =>\n (file: string, str: string, ...rest: Rest): Promise<T> =>\n fn(file, linesOf(str), ...rest)\n\nconst convertChunkBased =\n <T, Rest extends any[]>(\n fn: (\n file: string,\n lines: Iterable<string> | AsyncIterable<string>,\n ...rest: Rest\n ) => Promise<T>\n ) =>\n (file: string, str: string, ...rest: Rest): Promise<T> =>\n fn(file, [str], ...rest)\n\nexport const parseFrcsSurveyFile = convertChunkBased(_parseFrcsSurveyFile)\nexport const parseFrcsPlotFile = convertLineBased(_parseFrcsPlotFile)\nexport const parseFrcsTripSummaryFile = convertLineBased(\n _parseFrcsTripSummaryFile\n)\n"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,gBAAgBG,OAAOA,CAACC,CAAS,EAAyB;EACxD,OAAOA,CAAC,CAACC,KAAK,CAAC,YAAY,CAAC;AAC9B;AACA,MAAMC,gBAAgB,GAElBC,EAIe,IAEjB,CAACC,IAAY,EAAEC,GAAW,EAAE,GAAGC,IAAU,KACvCH,EAAE,CAACC,IAAI,EAAEL,OAAO,CAACM,GAAG,CAAC,EAAE,GAAGC,IAAI,CAAC;AAEnC,MAAMC,iBAAiB,GAEnBJ,EAIe,IAEjB,CAACC,IAAY,EAAEC,GAAW,EAAE,GAAGC,IAAU,KACvCH,EAAE,CAACC,IAAI,EAAE,CAACC,GAAG,CAAC,EAAE,GAAGC,IAAI,CAAC;AAErB,MAAME,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGD,iBAAiB,CAACG,6BAAoB,CAAC;AACnE,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAGT,gBAAgB,CAACU,2BAAkB,CAAC;AAC9D,MAAMC,wBAAwB,GAAAJ,OAAA,CAAAI,wBAAA,GAAGX,gBAAgB,CACtDY,kCACF,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.defaultFrcsShotColumnConfig = void 0;
7
7
  // eslint-disable-next-line @typescript-eslint/ban-types
8
8
 
9
- var defaultFrcsShotColumnConfig = exports.defaultFrcsShotColumnConfig = {
9
+ const defaultFrcsShotColumnConfig = exports.defaultFrcsShotColumnConfig = {
10
10
  toStation: 5,
11
11
  fromStation: 5,
12
12
  distance: 6,