@dra2020/baseclient 1.0.56 → 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/all/all.d.ts CHANGED
@@ -20,3 +20,5 @@ import * as G from '../geo/all';
20
20
  export { G };
21
21
  import * as Emit from '../emit/all';
22
22
  export { Emit };
23
+ import * as CSV from '../csv/all';
24
+ export { CSV };
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
39
39
  return result;
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", ({ value: true }));
42
- exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
42
+ exports.CSV = exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
43
43
  // Client and Server
44
44
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
45
45
  exports.Util = Util;
@@ -63,6 +63,8 @@ const G = __importStar(__webpack_require__(/*! ../geo/all */ "./lib/geo/all.ts")
63
63
  exports.G = G;
64
64
  const Emit = __importStar(__webpack_require__(/*! ../emit/all */ "./lib/emit/all.ts"));
65
65
  exports.Emit = Emit;
66
+ const CSV = __importStar(__webpack_require__(/*! ../csv/all */ "./lib/csv/all.ts"));
67
+ exports.CSV = CSV;
66
68
 
67
69
 
68
70
  /***/ }),
@@ -169,6 +171,150 @@ function create() {
169
171
  exports.create = create;
170
172
 
171
173
 
174
+ /***/ }),
175
+
176
+ /***/ "./lib/csv/all.ts":
177
+ /*!************************!*\
178
+ !*** ./lib/csv/all.ts ***!
179
+ \************************/
180
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
181
+
182
+
183
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
184
+ if (k2 === undefined) k2 = k;
185
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
186
+ }) : (function(o, m, k, k2) {
187
+ if (k2 === undefined) k2 = k;
188
+ o[k2] = m[k];
189
+ }));
190
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
191
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
192
+ };
193
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
194
+ __exportStar(__webpack_require__(/*! ./csv */ "./lib/csv/csv.ts"), exports);
195
+
196
+
197
+ /***/ }),
198
+
199
+ /***/ "./lib/csv/csv.ts":
200
+ /*!************************!*\
201
+ !*** ./lib/csv/csv.ts ***!
202
+ \************************/
203
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
204
+
205
+
206
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
207
+ if (k2 === undefined) k2 = k;
208
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
209
+ }) : (function(o, m, k, k2) {
210
+ if (k2 === undefined) k2 = k;
211
+ o[k2] = m[k];
212
+ }));
213
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
214
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
215
+ }) : function(o, v) {
216
+ o["default"] = v;
217
+ });
218
+ var __importStar = (this && this.__importStar) || function (mod) {
219
+ if (mod && mod.__esModule) return mod;
220
+ var result = {};
221
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
222
+ __setModuleDefault(result, mod);
223
+ return result;
224
+ };
225
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
226
+ exports.ParseOne = void 0;
227
+ const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
228
+ // Parse CSV.
229
+ // Fields are separated by commas or pipe symbol (census uses pipe separators.
230
+ // Quoted fields may contain commas or pipes.
231
+ // Either single quotes or double quotes may be used to surround field value.
232
+ // Spaces at the beginning and end of fields are ignored.
233
+ // Quotes must be the first non-space character in the field (otherwise they are part of the field value).
234
+ //
235
+ const Space = 32;
236
+ const Tab = 9;
237
+ const Newline = 10;
238
+ const CR = 13;
239
+ const Comma = 44;
240
+ const SingleQuote = 39;
241
+ const DoubleQuote = 34;
242
+ const BackSlash = 92;
243
+ const Pipe = 124;
244
+ function isWhite(c) {
245
+ return c === Space || c === Newline || c === Tab || c == CR;
246
+ }
247
+ class ParseOne {
248
+ constructor(coder, line) {
249
+ this.coder = coder;
250
+ if (line)
251
+ this.set(line);
252
+ else
253
+ this.fields = [];
254
+ }
255
+ set(line) {
256
+ this.fields = [];
257
+ this.buf = Util.s2u8(this.coder, line);
258
+ this.tok = new Uint8Array(new ArrayBuffer(this.buf.length));
259
+ this.n = 0;
260
+ this.toklen = 0;
261
+ this.infield = false;
262
+ this.nwhite = 0;
263
+ this.quote = 0;
264
+ this.force = false;
265
+ this.parse();
266
+ }
267
+ get length() { return this.fields.length; }
268
+ pushtok() {
269
+ // Trim trailing whitespace
270
+ this.toklen -= this.nwhite;
271
+ if (this.toklen || this.force) {
272
+ this.fields.push(Util.u82s(this.coder, this.tok, 0, this.toklen));
273
+ this.toklen = 0;
274
+ }
275
+ this.infield = false;
276
+ this.nwhite = 0;
277
+ this.quote = 0;
278
+ this.force = false;
279
+ }
280
+ parse() {
281
+ while (this.n < this.buf.length) {
282
+ let c = this.buf[this.n++];
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
+ }
292
+ else if (this.infield) {
293
+ this.tok[this.toklen++] = c;
294
+ if (!this.quote && isWhite(c))
295
+ this.nwhite++;
296
+ else
297
+ this.nwhite = 0;
298
+ }
299
+ else if (isWhite(c))
300
+ continue;
301
+ else if (c === SingleQuote || c === DoubleQuote) {
302
+ this.quote = c;
303
+ this.infield = true;
304
+ this.force = true;
305
+ }
306
+ else {
307
+ this.infield = true;
308
+ this.tok[this.toklen++] = c;
309
+ this.force = true;
310
+ }
311
+ }
312
+ this.pushtok();
313
+ }
314
+ }
315
+ exports.ParseOne = ParseOne;
316
+
317
+
172
318
  /***/ }),
173
319
 
174
320
  /***/ "./lib/emit/all.ts":
@@ -1314,6 +1460,44 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1314
1460
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1315
1461
  __exportStar(__webpack_require__(/*! ./geo */ "./lib/geo/geo.ts"), exports);
1316
1462
  __exportStar(__webpack_require__(/*! ./vfeature */ "./lib/geo/vfeature.ts"), exports);
1463
+ __exportStar(__webpack_require__(/*! ./flexname */ "./lib/geo/flexname.ts"), exports);
1464
+
1465
+
1466
+ /***/ }),
1467
+
1468
+ /***/ "./lib/geo/flexname.ts":
1469
+ /*!*****************************!*\
1470
+ !*** ./lib/geo/flexname.ts ***!
1471
+ \*****************************/
1472
+ /***/ ((__unused_webpack_module, exports) => {
1473
+
1474
+
1475
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1476
+ exports.flexName = void 0;
1477
+ function flexName(f) {
1478
+ if (!f || !f.properties)
1479
+ return null;
1480
+ let oneOf = ['name', 'entry_name', 'Name', 'NAME',
1481
+ 'NAMELSAD', 'namelsad',
1482
+ 'NAME10', 'name10',
1483
+ 'NAMELSAD10', 'namelsad10',
1484
+ 'NAME20', 'name20',
1485
+ 'NAMELSAD20', 'namelsad20',
1486
+ 'NAME30', 'name30',
1487
+ 'NAMELSAD30', 'namelsad30',
1488
+ ];
1489
+ for (let i = 0; i < oneOf.length; i++)
1490
+ if (f.properties[oneOf[i]] !== undefined) {
1491
+ let name = f.properties[oneOf[i]];
1492
+ if (name.startsWith('Block Group') && f.properties['GEOID10'] !== undefined)
1493
+ return String(f.properties['GEOID10']).substr(2);
1494
+ name = name.replace('Voting Districts', '');
1495
+ name = name.replace('Precinct', '');
1496
+ return name.replace('Voting District', '').trim();
1497
+ }
1498
+ return `${f.properties.id}`;
1499
+ }
1500
+ exports.flexName = flexName;
1317
1501
 
1318
1502
 
1319
1503
  /***/ }),