@dra2020/baseclient 1.0.19 → 1.0.22

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
@@ -18,3 +18,5 @@ import { FilterExpr } from '../filterexpr/all';
18
18
  export { FilterExpr };
19
19
  import * as G from '../geo/all';
20
20
  export { G };
21
+ import * as Emit from '../emit/all';
22
+ export { Emit };
@@ -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.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
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;
43
43
  // Client and Server
44
44
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
45
45
  exports.Util = Util;
@@ -61,6 +61,8 @@ const all_1 = __webpack_require__(/*! ../filterexpr/all */ "./lib/filterexpr/all
61
61
  Object.defineProperty(exports, "FilterExpr", ({ enumerable: true, get: function () { return all_1.FilterExpr; } }));
62
62
  const G = __importStar(__webpack_require__(/*! ../geo/all */ "./lib/geo/all.ts"));
63
63
  exports.G = G;
64
+ const Emit = __importStar(__webpack_require__(/*! ../emit/all */ "./lib/emit/all.ts"));
65
+ exports.Emit = Emit;
64
66
 
65
67
 
66
68
  /***/ }),
@@ -167,6 +169,71 @@ function create() {
167
169
  exports.create = create;
168
170
 
169
171
 
172
+ /***/ }),
173
+
174
+ /***/ "./lib/emit/all.ts":
175
+ /*!*************************!*\
176
+ !*** ./lib/emit/all.ts ***!
177
+ \*************************/
178
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
179
+
180
+
181
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
182
+ if (k2 === undefined) k2 = k;
183
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
184
+ }) : (function(o, m, k, k2) {
185
+ if (k2 === undefined) k2 = k;
186
+ o[k2] = m[k];
187
+ }));
188
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
189
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
190
+ };
191
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
192
+ __exportStar(__webpack_require__(/*! ./emit */ "./lib/emit/emit.ts"), exports);
193
+
194
+
195
+ /***/ }),
196
+
197
+ /***/ "./lib/emit/emit.ts":
198
+ /*!**************************!*\
199
+ !*** ./lib/emit/emit.ts ***!
200
+ \**************************/
201
+ /***/ ((__unused_webpack_module, exports) => {
202
+
203
+
204
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
205
+ exports.Emit = void 0;
206
+ class Emit {
207
+ constructor() {
208
+ this.onList = {};
209
+ }
210
+ on(eventName, cb) {
211
+ let aCB = this.onList[eventName];
212
+ if (aCB === undefined) {
213
+ aCB = [];
214
+ this.onList[eventName] = aCB;
215
+ }
216
+ aCB.push(cb);
217
+ }
218
+ emit(eventName, arg1, arg2, arg3) {
219
+ let aCB = this.onList[eventName];
220
+ if (aCB !== undefined)
221
+ for (let i = 0; i < aCB.length; i++)
222
+ (aCB[i])(arg1, arg2, arg3);
223
+ }
224
+ off(eventName, cb) {
225
+ let aCB = this.onList[eventName];
226
+ if (aCB !== undefined)
227
+ for (let i = 0; i < aCB.length; i++)
228
+ if (aCB[i] === cb) {
229
+ aCB.splice(i, 1);
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ exports.Emit = Emit;
235
+
236
+
170
237
  /***/ }),
171
238
 
172
239
  /***/ "./lib/filterexpr/all.ts":
@@ -8826,21 +8893,31 @@ __exportStar(__webpack_require__(/*! ./bintrie */ "./lib/util/bintrie.ts"), expo
8826
8893
  /*!*****************************!*\
8827
8894
  !*** ./lib/util/bintrie.ts ***!
8828
8895
  \*****************************/
8829
- /***/ ((__unused_webpack_module, exports) => {
8896
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
8830
8897
 
8831
8898
 
8832
- //
8833
- // Packed format Trie for mapping string to string
8834
- // Assumptions:
8835
- // 1. Lots of duplicate prefix strings in keys (so branching in trie happens late).
8836
- // 2. Lots of duplicate prefix strings in values.
8837
- // 3. Lots of keys with duplicate prefix map to the same string value.
8838
- // Especially good for something like our blockmapping.json file since both the keys (blockIDs)
8839
- // and values (precinct IDs) have a ton of redundancy and ~250 avg keys (blockID) map to same
8840
- // precinctID.
8841
- // The packed structure is just read directly into memory and walked in packed format.
8899
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8900
+ if (k2 === undefined) k2 = k;
8901
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8902
+ }) : (function(o, m, k, k2) {
8903
+ if (k2 === undefined) k2 = k;
8904
+ o[k2] = m[k];
8905
+ }));
8906
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
8907
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
8908
+ }) : function(o, v) {
8909
+ o["default"] = v;
8910
+ });
8911
+ var __importStar = (this && this.__importStar) || function (mod) {
8912
+ if (mod && mod.__esModule) return mod;
8913
+ var result = {};
8914
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
8915
+ __setModuleDefault(result, mod);
8916
+ return result;
8917
+ };
8842
8918
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8843
8919
  exports.BinTrieBuilder = exports.BinTrie = exports.u82s = exports.s2u8 = void 0;
8920
+ const U = __importStar(__webpack_require__(/*! ./util */ "./lib/util/util.ts"));
8844
8921
  /*
8845
8922
  -- For Node
8846
8923
  import * as u from 'util';
@@ -8849,6 +8926,7 @@ Util.setCoder({ encoder: new u.TextEncoder(), decoder: new u.TextDecoder('utf-8'
8849
8926
  -- For Browser
8850
8927
  Util.setCoder({ encoder: new TextEncoder(), decoder: new TextDecoder('utf-8') });
8851
8928
  */
8929
+ const MaxKeyLength = 128;
8852
8930
  function s2u8(coder, s) {
8853
8931
  return coder.encoder.encode(s);
8854
8932
  }
@@ -9050,11 +9128,26 @@ class BinTrie {
9050
9128
  }
9051
9129
  return undefined;
9052
9130
  }
9131
+ forEach(cb) {
9132
+ let keybuf = new Uint8Array(MaxKeyLength);
9133
+ let keylen = 0;
9134
+ let processNode = (len, byteOffset) => {
9135
+ let iOffset = byteOffset >> 2;
9136
+ let n = this.i32[iOffset];
9137
+ byteOffset += 4;
9138
+ for (let j = 0; j < n; j++) {
9139
+ keybuf[keylen++] = this.u8[byteOffset + j];
9140
+ }
9141
+ };
9142
+ processNode(0, 4);
9143
+ }
9053
9144
  }
9054
9145
  exports.BinTrie = BinTrie;
9146
+ let DefaultOptions = { dedup: true, verbose: false };
9055
9147
  class BinTrieBuilder {
9056
- constructor(coder) {
9148
+ constructor(coder, options) {
9057
9149
  this.coder = coder;
9150
+ this.options = U.shallowAssignImmutable(DefaultOptions, options);
9058
9151
  }
9059
9152
  // Building
9060
9153
  nodeCount(node) {
@@ -9203,8 +9296,8 @@ class BinTrieBuilder {
9203
9296
  this.u8[k] = u8[j];
9204
9297
  }
9205
9298
  // Building
9206
- static fromMap(coder, o) {
9207
- let btb = new BinTrieBuilder(coder);
9299
+ static fromMap(coder, o, options) {
9300
+ let btb = new BinTrieBuilder(coder, options);
9208
9301
  btb.vtb = ValueTableBuilder.fromStrings(coder, Object.values(o));
9209
9302
  btb.vt = ValueTable.fromBuffer(coder, btb.vtb.ab, 0, btb.vtb.ab.byteLength);
9210
9303
  let keys = Object.keys(o);
@@ -9219,7 +9312,8 @@ class BinTrieBuilder {
9219
9312
  }
9220
9313
  });
9221
9314
  // dedup (collapse branches pointing to same value)
9222
- btb.dedup(btb.root);
9315
+ if (btb.options.dedup)
9316
+ btb.dedup(btb.root);
9223
9317
  // validate
9224
9318
  keys.forEach(k => {
9225
9319
  if (good && btb.getUnpacked(k) !== o[k]) {
@@ -9244,7 +9338,8 @@ class BinTrieBuilder {
9244
9338
  good = false;
9245
9339
  }
9246
9340
  });
9247
- console.log(`bintrie: total size: ${btb.u8.length}, value table size: ${btb.vtb.u8.length}`);
9341
+ if (btb.options.verbose)
9342
+ console.log(`bintrie: total size: ${btb.u8.length}, value table size: ${btb.vtb.u8.length}`);
9248
9343
  return bt;
9249
9344
  }
9250
9345
  }