@speleotica/frcsdata 4.0.0 → 4.0.1

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 (42) hide show
  1. package/FrcsPlotFile.js +5 -1
  2. package/FrcsPlotShot.js +5 -1
  3. package/FrcsShot.js +4 -5
  4. package/FrcsSurveyFile.js +5 -1
  5. package/FrcsTrip.js +5 -1
  6. package/FrcsTripSummary.js +5 -1
  7. package/FrcsTripSummaryFile.js +5 -1
  8. package/es/FrcsPlotFile.js +5 -1
  9. package/es/FrcsPlotShot.js +5 -1
  10. package/es/FrcsShot.js +5 -6
  11. package/es/FrcsSurveyFile.js +5 -1
  12. package/es/FrcsTrip.js +5 -1
  13. package/es/FrcsTripSummary.js +5 -1
  14. package/es/FrcsTripSummaryFile.js +5 -1
  15. package/es/formatFrcsShot.js +5 -19
  16. package/es/formatFrcsShot.spec.js +8 -17
  17. package/es/index.js +21 -33
  18. package/es/node/index.js +2 -10
  19. package/es/node/parseFrcsPlotFile.spec.js +1 -5
  20. package/es/node/parseFrcsSurveyFile.spec.js +2 -6
  21. package/es/node/parseFrcsTripSummaryFile.spec.js +1 -5
  22. package/es/parseFrcsPlotFile.js +1 -26
  23. package/es/parseFrcsSurveyFile.js +45 -95
  24. package/es/parseFrcsTripSummaryFile.js +1 -12
  25. package/es/string/index.js +2 -9
  26. package/es/string/parseFrcsPlotFile.spec.js +1 -5
  27. package/es/string/parseFrcsSurveyFile.spec.js +8 -14
  28. package/formatFrcsShot.js +5 -19
  29. package/formatFrcsShot.spec.js +4 -15
  30. package/index.js +20 -32
  31. package/node/index.js +1 -9
  32. package/node/parseFrcsPlotFile.spec.js +165 -180
  33. package/node/parseFrcsSurveyFile.spec.js +306 -321
  34. package/node/parseFrcsTripSummaryFile.spec.js +83 -106
  35. package/package.json +15 -15
  36. package/parseFrcsPlotFile.js +224 -318
  37. package/parseFrcsSurveyFile.js +411 -452
  38. package/parseFrcsTripSummaryFile.js +102 -142
  39. package/string/index.js +10 -27
  40. package/string/parseFrcsPlotFile.spec.js +165 -180
  41. package/string/parseFrcsSurveyFile.spec.js +598 -689
  42. package/yarn.lock +1285 -702
@@ -1,22 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = parseFrcsTripSummaryFile;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
- var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
17
-
18
11
  var _unitized = require("@speleotica/unitized");
19
-
12
+ function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
13
+ function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
20
14
  var tripSummaryRegex = /^\s*(\d+)\s+(\d{1,2})\/(\s\d|\d\d)\/(\d{2,4})\s+(\d+(?:\.\d*)?)\s+(\d+)\s+(\S.*)EXCLUDED:\s+(\d+(?:\.\d*)?)\s+(\d+)/;
21
15
  /**
22
16
  * Parses data from a STAT_sum.txt file. Here is an excerpt of the format:
@@ -32,149 +26,115 @@ var tripSummaryRegex = /^\s*(\d+)\s+(\d{1,2})\/(\s\d|\d\d)\/(\d{2,4})\s+(\d+(?:\
32
26
  B6-B18 B17 SIDE B19-B38 B32 SIDE
33
27
  BS1-BS5 C1-C18 </pre>
34
28
  */
35
-
36
29
  function parseFrcsTripSummaryFile(_x, _x2) {
37
30
  return _parseFrcsTripSummaryFile.apply(this, arguments);
38
31
  }
39
-
40
32
  function _parseFrcsTripSummaryFile() {
41
- _parseFrcsTripSummaryFile = (0, _asyncToGenerator2["default"])(
42
- /*#__PURE__*/
43
- _regenerator["default"].mark(function _callee(file, lines) {
44
- var errors, tripSummaries, tripStartLine, lineNumber, team, shots, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, line, match, tripNumber, tripIndex, year, date, totalLength, numShots, name, excludedLength, numExcludedShots, _team, _shots, trimmed;
45
-
33
+ _parseFrcsTripSummaryFile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file, lines) {
34
+ var 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;
46
35
  return _regenerator["default"].wrap(function _callee$(_context) {
47
- while (1) {
48
- switch (_context.prev = _context.next) {
49
- case 0:
50
- errors = [];
51
- tripSummaries = [];
52
- tripStartLine = -2;
53
- lineNumber = 0;
54
- team = [];
55
- shots = [];
56
- _iteratorNormalCompletion = true;
57
- _didIteratorError = false;
58
- _context.prev = 8;
59
- _iterator = (0, _asyncIterator2["default"])(lines);
60
-
61
- case 10:
62
- _context.next = 12;
63
- return _iterator.next();
64
-
65
- case 12:
66
- _step = _context.sent;
67
- _iteratorNormalCompletion = _step.done;
68
- _context.next = 16;
69
- return _step.value;
70
-
71
- case 16:
72
- _value = _context.sent;
73
-
74
- if (_iteratorNormalCompletion) {
75
- _context.next = 41;
76
- break;
77
- }
78
-
79
- line = _value;
80
- lineNumber++;
81
- match = tripSummaryRegex.exec(line);
82
-
83
- if (!match) {
84
- _context.next = 37;
85
- break;
86
- }
87
-
88
- tripStartLine = lineNumber;
89
- tripNumber = parseInt(match[1]);
90
- tripIndex = tripNumber - 1;
91
- year = parseInt(match[4]);
92
- if (year < 1000) year += 1900;
93
- date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]));
94
- totalLength = _unitized.Unitize.feet(parseFloat(match[5]));
95
- numShots = parseInt(match[6]);
96
- name = match[7].trim();
97
- excludedLength = _unitized.Unitize.feet(parseFloat(match[8]));
98
- numExcludedShots = parseInt(match[9]);
99
- team = [];
100
- shots = [];
101
- tripSummaries[tripIndex] = {
102
- tripNumber: tripNumber,
103
- tripIndex: tripIndex,
104
- date: date,
105
- totalLength: totalLength,
106
- numShots: numShots,
107
- name: name,
108
- excludedLength: excludedLength,
109
- numExcludedShots: numExcludedShots,
110
- team: team,
111
- shots: shots
112
- };
113
- return _context.abrupt("continue", 38);
114
-
115
- case 37:
116
- if (lineNumber === tripStartLine + 1) {
117
- (_team = team).push.apply(_team, (0, _toConsumableArray2["default"])(line.trim().split(/\s\s+|\t+/g)));
118
- } else {
119
- trimmed = line.trim();
120
- if (trimmed) (_shots = shots).push.apply(_shots, (0, _toConsumableArray2["default"])(trimmed.split(/\s\s+|\t+/)));
121
- }
122
-
123
- case 38:
124
- _iteratorNormalCompletion = true;
125
- _context.next = 10;
36
+ while (1) switch (_context.prev = _context.next) {
37
+ case 0:
38
+ errors = [];
39
+ tripSummaries = [];
40
+ tripStartLine = -2;
41
+ lineNumber = 0;
42
+ team = [];
43
+ shots = [];
44
+ _iteratorAbruptCompletion = false;
45
+ _didIteratorError = false;
46
+ _context.prev = 8;
47
+ _iterator = _asyncIterator(lines);
48
+ case 10:
49
+ _context.next = 12;
50
+ return _iterator.next();
51
+ case 12:
52
+ if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
53
+ _context.next = 36;
126
54
  break;
127
-
128
- case 41:
55
+ }
56
+ line = _step.value;
57
+ lineNumber++;
58
+ match = tripSummaryRegex.exec(line);
59
+ if (!match) {
60
+ _context.next = 32;
61
+ break;
62
+ }
63
+ tripStartLine = lineNumber;
64
+ tripNumber = parseInt(match[1]);
65
+ tripIndex = tripNumber - 1;
66
+ year = parseInt(match[4]);
67
+ if (year < 1000) year += 1900;
68
+ date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]));
69
+ totalLength = _unitized.Unitize.feet(parseFloat(match[5]));
70
+ numShots = parseInt(match[6]);
71
+ name = match[7].trim();
72
+ excludedLength = _unitized.Unitize.feet(parseFloat(match[8]));
73
+ numExcludedShots = parseInt(match[9]);
74
+ team = [];
75
+ shots = [];
76
+ tripSummaries[tripIndex] = {
77
+ tripNumber: tripNumber,
78
+ tripIndex: tripIndex,
79
+ date: date,
80
+ totalLength: totalLength,
81
+ numShots: numShots,
82
+ name: name,
83
+ excludedLength: excludedLength,
84
+ numExcludedShots: numExcludedShots,
85
+ team: team,
86
+ shots: shots
87
+ };
88
+ return _context.abrupt("continue", 33);
89
+ case 32:
90
+ if (lineNumber === tripStartLine + 1) {
91
+ (_team = team).push.apply(_team, (0, _toConsumableArray2["default"])(line.trim().split(/\s\s+|\t+/g)));
92
+ } else {
93
+ trimmed = line.trim();
94
+ if (trimmed) (_shots = shots).push.apply(_shots, (0, _toConsumableArray2["default"])(trimmed.split(/\s\s+|\t+/)));
95
+ }
96
+ case 33:
97
+ _iteratorAbruptCompletion = false;
98
+ _context.next = 10;
99
+ break;
100
+ case 36:
101
+ _context.next = 42;
102
+ break;
103
+ case 38:
104
+ _context.prev = 38;
105
+ _context.t0 = _context["catch"](8);
106
+ _didIteratorError = true;
107
+ _iteratorError = _context.t0;
108
+ case 42:
109
+ _context.prev = 42;
110
+ _context.prev = 43;
111
+ if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
129
112
  _context.next = 47;
130
113
  break;
131
-
132
- case 43:
133
- _context.prev = 43;
134
- _context.t0 = _context["catch"](8);
135
- _didIteratorError = true;
136
- _iteratorError = _context.t0;
137
-
138
- case 47:
139
- _context.prev = 47;
140
- _context.prev = 48;
141
-
142
- if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) {
143
- _context.next = 52;
144
- break;
145
- }
146
-
147
- _context.next = 52;
148
- return _iterator["return"]();
149
-
150
- case 52:
151
- _context.prev = 52;
152
-
153
- if (!_didIteratorError) {
154
- _context.next = 55;
155
- break;
156
- }
157
-
158
- throw _iteratorError;
159
-
160
- case 55:
161
- return _context.finish(52);
162
-
163
- case 56:
164
- return _context.finish(47);
165
-
166
- case 57:
167
- return _context.abrupt("return", {
168
- errors: errors,
169
- tripSummaries: tripSummaries
170
- });
171
-
172
- case 58:
173
- case "end":
174
- return _context.stop();
175
- }
114
+ }
115
+ _context.next = 47;
116
+ return _iterator["return"]();
117
+ case 47:
118
+ _context.prev = 47;
119
+ if (!_didIteratorError) {
120
+ _context.next = 50;
121
+ break;
122
+ }
123
+ throw _iteratorError;
124
+ case 50:
125
+ return _context.finish(47);
126
+ case 51:
127
+ return _context.finish(42);
128
+ case 52:
129
+ return _context.abrupt("return", {
130
+ errors: errors,
131
+ tripSummaries: tripSummaries
132
+ });
133
+ case 53:
134
+ case "end":
135
+ return _context.stop();
176
136
  }
177
- }, _callee, null, [[8, 43, 47, 57], [48,, 52, 56]]);
137
+ }, _callee, null, [[8, 38, 42, 52], [43,, 47, 51]]);
178
138
  }));
179
139
  return _parseFrcsTripSummaryFile.apply(this, arguments);
180
140
  }
package/string/index.js CHANGED
@@ -1,58 +1,41 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.parseFrcsTripSummaryFile = exports.parseFrcsPlotFile = exports.parseFrcsSurveyFile = void 0;
9
-
7
+ exports.parseFrcsTripSummaryFile = exports.parseFrcsSurveyFile = exports.parseFrcsPlotFile = void 0;
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
13
-
14
10
  var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
15
-
16
- var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
17
-
18
11
  var _asyncGeneratorDelegate2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncGeneratorDelegate"));
19
-
20
12
  var _parseFrcsSurveyFile2 = _interopRequireDefault(require("../parseFrcsSurveyFile"));
21
-
22
13
  var _parseFrcsPlotFile2 = _interopRequireDefault(require("../parseFrcsPlotFile"));
23
-
24
14
  var _parseFrcsTripSummaryFile2 = _interopRequireDefault(require("../parseFrcsTripSummaryFile"));
25
-
15
+ function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
16
+ function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
26
17
  function linesOf(_x) {
27
18
  return _linesOf.apply(this, arguments);
28
19
  }
29
-
30
20
  function _linesOf() {
31
- _linesOf = (0, _wrapAsyncGenerator2["default"])(
32
- /*#__PURE__*/
33
- _regenerator["default"].mark(function _callee(s) {
21
+ _linesOf = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(s) {
34
22
  return _regenerator["default"].wrap(function _callee$(_context) {
35
- while (1) {
36
- switch (_context.prev = _context.next) {
37
- case 0:
38
- return _context.delegateYield((0, _asyncGeneratorDelegate2["default"])((0, _asyncIterator2["default"])(s.split(/\r\n?|\n/gm)), _awaitAsyncGenerator2["default"]), "t0", 1);
39
-
40
- case 1:
41
- case "end":
42
- return _context.stop();
43
- }
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();
44
29
  }
45
30
  }, _callee);
46
31
  }));
47
32
  return _linesOf.apply(this, arguments);
48
33
  }
49
-
50
34
  var convert = function convert(fn) {
51
35
  return function (file, str) {
52
36
  return fn(file, linesOf(str));
53
37
  };
54
38
  };
55
-
56
39
  var parseFrcsSurveyFile = convert(_parseFrcsSurveyFile2["default"]);
57
40
  exports.parseFrcsSurveyFile = parseFrcsSurveyFile;
58
41
  var parseFrcsPlotFile = convert(_parseFrcsPlotFile2["default"]);