@dra2020/baseclient 1.0.84 → 1.0.85
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 +42 -3
- package/dist/baseclient.js.map +1 -1
- package/dist/csv/csv.d.ts +10 -0
- package/docs/fsm.md +10 -6
- package/lib/csv/csv.ts +58 -2
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -889,7 +889,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
889
889
|
return result;
|
|
890
890
|
};
|
|
891
891
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
892
|
-
exports.ParseOne = void 0;
|
|
892
|
+
exports.ParseOne = exports.ParseMany = void 0;
|
|
893
893
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
894
894
|
// Parse CSV.
|
|
895
895
|
// Fields are separated by commas or pipe symbol (census uses pipe separators.
|
|
@@ -910,6 +910,41 @@ const Pipe = 124;
|
|
|
910
910
|
function isWhite(c) {
|
|
911
911
|
return c === Space || c === Newline || c === Tab || c == CR;
|
|
912
912
|
}
|
|
913
|
+
// Keep calling next() to retrieve next parsed line. Returns false when done. Empty lines are ignored.
|
|
914
|
+
class ParseMany {
|
|
915
|
+
constructor(coder, buf) {
|
|
916
|
+
this.buf = buf;
|
|
917
|
+
this.n = 0;
|
|
918
|
+
this.one = new ParseOne(coder);
|
|
919
|
+
}
|
|
920
|
+
get length() { return this.one.length; }
|
|
921
|
+
get fields() { return this.one.fields; }
|
|
922
|
+
next() {
|
|
923
|
+
// Move past any leading CRLF
|
|
924
|
+
while (this.n < this.buf.length) {
|
|
925
|
+
let c = this.buf[this.n];
|
|
926
|
+
if (c == CR || c == Newline)
|
|
927
|
+
this.n++;
|
|
928
|
+
else
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
let s = this.n;
|
|
932
|
+
while (this.n < this.buf.length) {
|
|
933
|
+
let c = this.buf[this.n];
|
|
934
|
+
if (c == CR || c == Newline)
|
|
935
|
+
break;
|
|
936
|
+
else
|
|
937
|
+
this.n++;
|
|
938
|
+
}
|
|
939
|
+
if (s != this.n) {
|
|
940
|
+
this.one.setBuf(this.buf.subarray(s, this.n));
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
else
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
exports.ParseMany = ParseMany;
|
|
913
948
|
class ParseOne {
|
|
914
949
|
constructor(coder, line) {
|
|
915
950
|
this.coder = coder;
|
|
@@ -919,9 +954,13 @@ class ParseOne {
|
|
|
919
954
|
this.fields = [];
|
|
920
955
|
}
|
|
921
956
|
set(line) {
|
|
957
|
+
this.setBuf(Util.s2u8(this.coder, line));
|
|
958
|
+
}
|
|
959
|
+
setBuf(buf) {
|
|
960
|
+
this.buf = buf;
|
|
922
961
|
this.fields = [];
|
|
923
|
-
this.
|
|
924
|
-
|
|
962
|
+
if (!this.tok || this.tok.length < this.buf.length)
|
|
963
|
+
this.tok = new Uint8Array(new ArrayBuffer(this.buf.length));
|
|
925
964
|
this.n = 0;
|
|
926
965
|
this.toklen = 0;
|
|
927
966
|
this.infield = false;
|