@dra2020/baseclient 1.0.59 → 1.0.60
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.
- package/dist/baseclient.js +22 -10
- package/dist/baseclient.js.map +1 -1
- package/dist/csv/csv.d.ts +18 -1
- package/lib/csv/csv.ts +22 -9
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -223,6 +223,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
223
223
|
return result;
|
|
224
224
|
};
|
|
225
225
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
226
|
+
exports.ParseOne = void 0;
|
|
226
227
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
227
228
|
// Parse CSV.
|
|
228
229
|
// Fields are separated by commas or pipe symbol (census uses pipe separators.
|
|
@@ -248,6 +249,8 @@ class ParseOne {
|
|
|
248
249
|
this.coder = coder;
|
|
249
250
|
if (line)
|
|
250
251
|
this.set(line);
|
|
252
|
+
else
|
|
253
|
+
this.fields = [];
|
|
251
254
|
}
|
|
252
255
|
set(line) {
|
|
253
256
|
this.fields = [];
|
|
@@ -258,31 +261,37 @@ class ParseOne {
|
|
|
258
261
|
this.infield = false;
|
|
259
262
|
this.nwhite = 0;
|
|
260
263
|
this.quote = 0;
|
|
264
|
+
this.force = false;
|
|
261
265
|
this.parse();
|
|
262
266
|
}
|
|
263
267
|
get length() { return this.fields.length; }
|
|
264
|
-
pushtok(
|
|
268
|
+
pushtok() {
|
|
265
269
|
// Trim trailing whitespace
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (this.toklen || force) {
|
|
270
|
+
this.toklen -= this.nwhite;
|
|
271
|
+
if (this.toklen || this.force) {
|
|
269
272
|
this.fields.push(Util.u82s(this.coder, this.tok, 0, this.toklen));
|
|
270
273
|
this.toklen = 0;
|
|
271
274
|
}
|
|
272
275
|
this.infield = false;
|
|
273
276
|
this.nwhite = 0;
|
|
274
277
|
this.quote = 0;
|
|
278
|
+
this.force = false;
|
|
275
279
|
}
|
|
276
280
|
parse() {
|
|
277
281
|
while (this.n < this.buf.length) {
|
|
278
282
|
let c = this.buf[this.n++];
|
|
279
|
-
if (this.quote && c === this.quote)
|
|
280
|
-
this.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
+
if (this.quote && c === this.quote) {
|
|
284
|
+
this.quote = 0;
|
|
285
|
+
this.nwhite = 0;
|
|
286
|
+
}
|
|
287
|
+
else if (c === Comma || c === Pipe) {
|
|
288
|
+
this.force = true;
|
|
289
|
+
this.pushtok();
|
|
290
|
+
this.force = true;
|
|
291
|
+
}
|
|
283
292
|
else if (this.infield) {
|
|
284
293
|
this.tok[this.toklen++] = c;
|
|
285
|
-
if (isWhite(c))
|
|
294
|
+
if (!this.quote && isWhite(c))
|
|
286
295
|
this.nwhite++;
|
|
287
296
|
else
|
|
288
297
|
this.nwhite = 0;
|
|
@@ -292,15 +301,18 @@ class ParseOne {
|
|
|
292
301
|
else if (c === SingleQuote || c === DoubleQuote) {
|
|
293
302
|
this.quote = c;
|
|
294
303
|
this.infield = true;
|
|
304
|
+
this.force = true;
|
|
295
305
|
}
|
|
296
306
|
else {
|
|
297
307
|
this.infield = true;
|
|
298
308
|
this.tok[this.toklen++] = c;
|
|
309
|
+
this.force = true;
|
|
299
310
|
}
|
|
300
311
|
}
|
|
301
|
-
this.pushtok(
|
|
312
|
+
this.pushtok();
|
|
302
313
|
}
|
|
303
314
|
}
|
|
315
|
+
exports.ParseOne = ParseOne;
|
|
304
316
|
|
|
305
317
|
|
|
306
318
|
/***/ }),
|