@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"] = parseFrcsPlotFile;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
15
-
16
10
  var _unitized = require("@speleotica/unitized");
17
-
18
11
  var _parseSegment = require("parse-segment");
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
  /**
21
15
  * Parses data from a calculated survey file. These look like so:
22
16
  <pre> 123.182259
@@ -34,328 +28,240 @@ var _parseSegment = require("parse-segment");
34
28
  function parseFrcsPlotFile(_x, _x2) {
35
29
  return _parseFrcsPlotFile.apply(this, arguments);
36
30
  }
37
-
38
31
  function _parseFrcsPlotFile() {
39
- _parseFrcsPlotFile = (0, _asyncToGenerator2["default"])(
40
- /*#__PURE__*/
41
- _regenerator["default"].mark(function _callee(file, lines) {
42
- var totalLength, shots, errors, lineNumber, error, parseUint, parseOptionalUint, parseLength, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, line, toName, isSurface, fromNumber, toNumber, easting, northing, elevation, leftEasting, leftNorthing, rightEasting, rightNorthing, up, down, tripNumber;
43
-
32
+ _parseFrcsPlotFile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file, lines) {
33
+ var totalLength, shots, errors, lineNumber, error, parseUint, parseOptionalUint, parseLength, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, toName, isSurface, fromNumber, toNumber, easting, northing, elevation, leftEasting, leftNorthing, rightEasting, rightNorthing, up, down, tripNumber;
44
34
  return _regenerator["default"].wrap(function _callee$(_context) {
45
- while (1) {
46
- switch (_context.prev = _context.next) {
47
- case 0:
48
- parseLength = function _ref3(line, startColumn, endColumn, fieldName, divisor) {
49
- var str = line.substring(startColumn, endColumn);
50
-
51
- if (!/^\s*-?\d+\s*$/.test(str)) {
52
- error("Invalid ".concat(fieldName), line, startColumn, endColumn);
53
- return null;
54
- }
55
-
56
- var value = parseFloat(str);
57
-
58
- if (isNaN(value)) {
59
- error("Missing ".concat(fieldName), line, startColumn, endColumn);
60
- return null;
61
- }
62
-
63
- return _unitized.Unitize.feet(value / divisor);
64
- };
65
-
66
- parseOptionalUint = function _ref2(line, startColumn, endColumn, fieldName) {
67
- var str = line.substring(startColumn, endColumn);
68
-
69
- if (!/\S/.test(str)) {
70
- return null;
71
- }
72
-
73
- if (!/^\s*\d+\s*$/.test(str)) {
74
- error("Invalid ".concat(fieldName), line, startColumn, endColumn);
75
- return null;
76
- }
77
-
78
- return parseInt(str);
79
- };
80
-
81
- parseUint = function _ref(line, startColumn, endColumn, fieldName) {
82
- var str = line.substring(startColumn, endColumn);
83
-
84
- if (!/\S/.test(str)) {
85
- error("Missing ".concat(fieldName), line, startColumn, endColumn);
86
- return null;
87
- }
88
-
89
- if (!/^\s*\d+\s*$/.test(str)) {
90
- error("Invalid ".concat(fieldName), line, startColumn, endColumn);
91
- return null;
92
- }
93
-
94
- return parseInt(str);
95
- };
96
-
97
- totalLength = _unitized.Unitize.feet(NaN);
98
- shots = [];
99
- errors = [];
100
- lineNumber = 0;
101
-
102
- error = function error(message, line, startColumn, endColumn) {
103
- errors.push(new _parseSegment.SegmentParseError(message, new _parseSegment.Segment({
104
- value: line,
105
- source: file,
106
- startLine: lineNumber - 1,
107
- startCol: 0
108
- }).substring(startColumn, endColumn)));
109
- };
110
-
111
- _iteratorNormalCompletion = true;
112
- _didIteratorError = false;
113
- _context.prev = 10;
114
- _iterator = (0, _asyncIterator2["default"])(lines);
115
-
116
- case 12:
117
- _context.next = 14;
118
- return _iterator.next();
119
-
120
- case 14:
121
- _step = _context.sent;
122
- _iteratorNormalCompletion = _step.done;
123
- _context.next = 18;
124
- return _step.value;
125
-
126
- case 18:
127
- _value = _context.sent;
128
-
129
- if (_iteratorNormalCompletion) {
130
- _context.next = 73;
131
- break;
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ parseLength = function _parseLength(line, startColumn, endColumn, fieldName, divisor) {
38
+ var str = line.substring(startColumn, endColumn);
39
+ if (!/^\s*-?\d+\s*$/.test(str)) {
40
+ error("Invalid ".concat(fieldName), line, startColumn, endColumn);
41
+ return null;
132
42
  }
133
-
134
- line = _value;
135
- lineNumber++;
136
-
137
- if (!(lineNumber === 1)) {
138
- _context.next = 25;
139
- break;
140
- }
141
-
142
- totalLength = _unitized.Unitize.feet(parseFloat(line));
143
- return _context.abrupt("continue", 70);
144
-
145
- case 25:
146
- if (/\S/.test(line)) {
147
- _context.next = 27;
148
- break;
149
- }
150
-
151
- return _context.abrupt("continue", 70);
152
-
153
- case 27:
154
- toName = line.substring(0, 6).trim();
155
-
156
- if (toName) {
157
- _context.next = 31;
158
- break;
159
- }
160
-
161
- error('Invalid to station name', line, 0, 6);
162
- return _context.abrupt("continue", 70);
163
-
164
- case 31:
165
- if (!/[^ S]/.test(line[6])) {
166
- _context.next = 34;
167
- break;
168
- }
169
-
170
- error('Invalid flag', line, 6, 7);
171
- return _context.abrupt("continue", 70);
172
-
173
- case 34:
174
- isSurface = line[6] === 'S';
175
- fromNumber = parseUint(line, 7, 12, 'from station number');
176
-
177
- if (!(fromNumber == null)) {
178
- _context.next = 38;
179
- break;
43
+ var value = parseFloat(str);
44
+ if (isNaN(value)) {
45
+ error("Missing ".concat(fieldName), line, startColumn, endColumn);
46
+ return null;
180
47
  }
181
-
182
- return _context.abrupt("continue", 70);
183
-
184
- case 38:
185
- toNumber = parseUint(line, 12, 17, 'to station number');
186
-
187
- if (!(toNumber == null)) {
188
- _context.next = 41;
189
- break;
48
+ return _unitized.Unitize.feet(value / divisor);
49
+ };
50
+ parseOptionalUint = function _parseOptionalUint(line, startColumn, endColumn, fieldName) {
51
+ var str = line.substring(startColumn, endColumn);
52
+ if (!/\S/.test(str)) {
53
+ return null;
190
54
  }
191
-
192
- return _context.abrupt("continue", 70);
193
-
194
- case 41:
195
- easting = parseLength(line, 17, 25, 'easting', 100);
196
-
197
- if (easting) {
198
- _context.next = 44;
199
- break;
55
+ if (!/^\s*\d+\s*$/.test(str)) {
56
+ error("Invalid ".concat(fieldName), line, startColumn, endColumn);
57
+ return null;
200
58
  }
201
-
202
- return _context.abrupt("continue", 70);
203
-
204
- case 44:
205
- northing = parseLength(line, 25, 33, 'northing', 100);
206
-
207
- if (northing) {
208
- _context.next = 47;
209
- break;
59
+ return parseInt(str);
60
+ };
61
+ parseUint = function _parseUint(line, startColumn, endColumn, fieldName) {
62
+ var str = line.substring(startColumn, endColumn);
63
+ if (!/\S/.test(str)) {
64
+ error("Missing ".concat(fieldName), line, startColumn, endColumn);
65
+ return null;
210
66
  }
211
-
212
- return _context.abrupt("continue", 70);
213
-
214
- case 47:
215
- elevation = parseLength(line, 33, 40, 'elevation', 100);
216
-
217
- if (elevation) {
218
- _context.next = 50;
219
- break;
67
+ if (!/^\s*\d+\s*$/.test(str)) {
68
+ error("Invalid ".concat(fieldName), line, startColumn, endColumn);
69
+ return null;
220
70
  }
221
-
222
- return _context.abrupt("continue", 70);
223
-
224
- case 50:
225
- leftEasting = parseLength(line, 40, 46, 'left wall easting', 100);
226
-
227
- if (leftEasting) {
228
- _context.next = 53;
229
- break;
230
- }
231
-
232
- return _context.abrupt("continue", 70);
233
-
234
- case 53:
235
- leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100);
236
-
237
- if (leftNorthing) {
238
- _context.next = 56;
239
- break;
240
- }
241
-
242
- return _context.abrupt("continue", 70);
243
-
244
- case 56:
245
- rightEasting = parseLength(line, 52, 58, 'right wall easting', 100);
246
-
247
- if (rightEasting) {
248
- _context.next = 59;
249
- break;
250
- }
251
-
252
- return _context.abrupt("continue", 70);
253
-
254
- case 59:
255
- rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100);
256
-
257
- if (rightNorthing) {
258
- _context.next = 62;
259
- break;
260
- }
261
-
262
- return _context.abrupt("continue", 70);
263
-
264
- case 62:
265
- up = parseLength(line, 64, 68, 'up', 10);
266
-
267
- if (up) {
268
- _context.next = 65;
269
- break;
270
- }
271
-
272
- return _context.abrupt("continue", 70);
273
-
274
- case 65:
275
- down = parseLength(line, 68, 72, 'down', 10);
276
-
277
- if (down) {
278
- _context.next = 68;
279
- break;
280
- }
281
-
282
- return _context.abrupt("continue", 70);
283
-
284
- case 68:
285
- tripNumber = parseOptionalUint(line, 72, 78, 'trip number');
286
- shots.push({
287
- toName: toName,
288
- isSurface: isSurface,
289
- fromNumber: fromNumber,
290
- toNumber: toNumber,
291
- easting: easting,
292
- northing: northing,
293
- elevation: elevation,
294
- leftEasting: leftEasting,
295
- leftNorthing: leftNorthing,
296
- rightEasting: rightEasting,
297
- rightNorthing: rightNorthing,
298
- up: up,
299
- down: down,
300
- tripNumber: tripNumber
301
- });
302
-
303
- case 70:
304
- _iteratorNormalCompletion = true;
305
- _context.next = 12;
71
+ return parseInt(str);
72
+ };
73
+ totalLength = _unitized.Unitize.feet(NaN);
74
+ shots = [];
75
+ errors = [];
76
+ lineNumber = 0;
77
+ error = function error(message, line, startColumn, endColumn) {
78
+ errors.push(new _parseSegment.SegmentParseError(message, new _parseSegment.Segment({
79
+ value: line,
80
+ source: file,
81
+ startLine: lineNumber - 1,
82
+ startCol: 0
83
+ }).substring(startColumn, endColumn)));
84
+ };
85
+ _iteratorAbruptCompletion = false;
86
+ _didIteratorError = false;
87
+ _context.prev = 10;
88
+ _iterator = _asyncIterator(lines);
89
+ case 12:
90
+ _context.next = 14;
91
+ return _iterator.next();
92
+ case 14:
93
+ if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
94
+ _context.next = 68;
306
95
  break;
307
-
308
- case 73:
96
+ }
97
+ line = _step.value;
98
+ lineNumber++;
99
+ if (!(lineNumber === 1)) {
100
+ _context.next = 20;
101
+ break;
102
+ }
103
+ totalLength = _unitized.Unitize.feet(parseFloat(line));
104
+ return _context.abrupt("continue", 65);
105
+ case 20:
106
+ if (/\S/.test(line)) {
107
+ _context.next = 22;
108
+ break;
109
+ }
110
+ return _context.abrupt("continue", 65);
111
+ case 22:
112
+ toName = line.substring(0, 6).trim();
113
+ if (toName) {
114
+ _context.next = 26;
115
+ break;
116
+ }
117
+ error('Invalid to station name', line, 0, 6);
118
+ return _context.abrupt("continue", 65);
119
+ case 26:
120
+ if (!/[^ S]/.test(line[6])) {
121
+ _context.next = 29;
122
+ break;
123
+ }
124
+ error('Invalid flag', line, 6, 7);
125
+ return _context.abrupt("continue", 65);
126
+ case 29:
127
+ isSurface = line[6] === 'S';
128
+ fromNumber = parseUint(line, 7, 12, 'from station number');
129
+ if (!(fromNumber == null)) {
130
+ _context.next = 33;
131
+ break;
132
+ }
133
+ return _context.abrupt("continue", 65);
134
+ case 33:
135
+ toNumber = parseUint(line, 12, 17, 'to station number');
136
+ if (!(toNumber == null)) {
137
+ _context.next = 36;
138
+ break;
139
+ }
140
+ return _context.abrupt("continue", 65);
141
+ case 36:
142
+ easting = parseLength(line, 17, 25, 'easting', 100);
143
+ if (easting) {
144
+ _context.next = 39;
145
+ break;
146
+ }
147
+ return _context.abrupt("continue", 65);
148
+ case 39:
149
+ northing = parseLength(line, 25, 33, 'northing', 100);
150
+ if (northing) {
151
+ _context.next = 42;
152
+ break;
153
+ }
154
+ return _context.abrupt("continue", 65);
155
+ case 42:
156
+ elevation = parseLength(line, 33, 40, 'elevation', 100);
157
+ if (elevation) {
158
+ _context.next = 45;
159
+ break;
160
+ }
161
+ return _context.abrupt("continue", 65);
162
+ case 45:
163
+ leftEasting = parseLength(line, 40, 46, 'left wall easting', 100);
164
+ if (leftEasting) {
165
+ _context.next = 48;
166
+ break;
167
+ }
168
+ return _context.abrupt("continue", 65);
169
+ case 48:
170
+ leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100);
171
+ if (leftNorthing) {
172
+ _context.next = 51;
173
+ break;
174
+ }
175
+ return _context.abrupt("continue", 65);
176
+ case 51:
177
+ rightEasting = parseLength(line, 52, 58, 'right wall easting', 100);
178
+ if (rightEasting) {
179
+ _context.next = 54;
180
+ break;
181
+ }
182
+ return _context.abrupt("continue", 65);
183
+ case 54:
184
+ rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100);
185
+ if (rightNorthing) {
186
+ _context.next = 57;
187
+ break;
188
+ }
189
+ return _context.abrupt("continue", 65);
190
+ case 57:
191
+ up = parseLength(line, 64, 68, 'up', 10);
192
+ if (up) {
193
+ _context.next = 60;
194
+ break;
195
+ }
196
+ return _context.abrupt("continue", 65);
197
+ case 60:
198
+ down = parseLength(line, 68, 72, 'down', 10);
199
+ if (down) {
200
+ _context.next = 63;
201
+ break;
202
+ }
203
+ return _context.abrupt("continue", 65);
204
+ case 63:
205
+ tripNumber = parseOptionalUint(line, 72, 78, 'trip number');
206
+ shots.push({
207
+ toName: toName,
208
+ isSurface: isSurface,
209
+ fromNumber: fromNumber,
210
+ toNumber: toNumber,
211
+ easting: easting,
212
+ northing: northing,
213
+ elevation: elevation,
214
+ leftEasting: leftEasting,
215
+ leftNorthing: leftNorthing,
216
+ rightEasting: rightEasting,
217
+ rightNorthing: rightNorthing,
218
+ up: up,
219
+ down: down,
220
+ tripNumber: tripNumber
221
+ });
222
+ case 65:
223
+ _iteratorAbruptCompletion = false;
224
+ _context.next = 12;
225
+ break;
226
+ case 68:
227
+ _context.next = 74;
228
+ break;
229
+ case 70:
230
+ _context.prev = 70;
231
+ _context.t0 = _context["catch"](10);
232
+ _didIteratorError = true;
233
+ _iteratorError = _context.t0;
234
+ case 74:
235
+ _context.prev = 74;
236
+ _context.prev = 75;
237
+ if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
309
238
  _context.next = 79;
310
239
  break;
311
-
312
- case 75:
313
- _context.prev = 75;
314
- _context.t0 = _context["catch"](10);
315
- _didIteratorError = true;
316
- _iteratorError = _context.t0;
317
-
318
- case 79:
319
- _context.prev = 79;
320
- _context.prev = 80;
321
-
322
- if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) {
323
- _context.next = 84;
324
- break;
325
- }
326
-
327
- _context.next = 84;
328
- return _iterator["return"]();
329
-
330
- case 84:
331
- _context.prev = 84;
332
-
333
- if (!_didIteratorError) {
334
- _context.next = 87;
335
- break;
336
- }
337
-
338
- throw _iteratorError;
339
-
340
- case 87:
341
- return _context.finish(84);
342
-
343
- case 88:
344
- return _context.finish(79);
345
-
346
- case 89:
347
- return _context.abrupt("return", {
348
- totalLength: totalLength,
349
- shots: shots,
350
- errors: errors
351
- });
352
-
353
- case 90:
354
- case "end":
355
- return _context.stop();
356
- }
240
+ }
241
+ _context.next = 79;
242
+ return _iterator["return"]();
243
+ case 79:
244
+ _context.prev = 79;
245
+ if (!_didIteratorError) {
246
+ _context.next = 82;
247
+ break;
248
+ }
249
+ throw _iteratorError;
250
+ case 82:
251
+ return _context.finish(79);
252
+ case 83:
253
+ return _context.finish(74);
254
+ case 84:
255
+ return _context.abrupt("return", {
256
+ totalLength: totalLength,
257
+ shots: shots,
258
+ errors: errors
259
+ });
260
+ case 85:
261
+ case "end":
262
+ return _context.stop();
357
263
  }
358
- }, _callee, null, [[10, 75, 79, 89], [80,, 84, 88]]);
264
+ }, _callee, null, [[10, 70, 74, 84], [75,, 79, 83]]);
359
265
  }));
360
266
  return _parseFrcsPlotFile.apply(this, arguments);
361
267
  }