@dra2020/baseclient 1.0.20 → 1.0.23

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.
@@ -0,0 +1 @@
1
+ export * from './emit';
@@ -0,0 +1,7 @@
1
+ export declare class Emit {
2
+ onList: any;
3
+ constructor();
4
+ on(eventName: string, cb: any): void;
5
+ emit(eventName: string, arg1?: any, arg2?: any, arg3?: any): void;
6
+ off(eventName: string, cb: any): void;
7
+ }
@@ -53,10 +53,12 @@ export declare type RevisionList = Revision[];
53
53
  export interface SessionUser {
54
54
  id: string;
55
55
  name: string;
56
+ twitterhandle: string;
56
57
  }
57
58
  export interface ActiveUser {
58
59
  id: string;
59
60
  name: string;
61
+ twitterhandle: string;
60
62
  active: number;
61
63
  }
62
64
  export interface SessionUserIndex {
@@ -69,9 +69,11 @@ export declare class BinTrie {
69
69
  constructor(coder: Coder);
70
70
  static fromBuffer(coder: Coder, ab: ArrayBuffer): BinTrie;
71
71
  get(key: string): string;
72
+ forEach(cb: (k: string, v: string) => void): void;
72
73
  }
73
74
  export interface BinTrieOptions {
74
75
  dedup?: boolean;
76
+ verbose?: boolean;
75
77
  }
76
78
  export declare class BinTrieBuilder {
77
79
  options: BinTrieOptions;
package/lib/all/all.ts CHANGED
@@ -19,3 +19,5 @@ import { FilterExpr } from '../filterexpr/all';
19
19
  export { FilterExpr }
20
20
  import * as G from '../geo/all';
21
21
  export { G };
22
+ import * as Emit from '../emit/all';
23
+ export { Emit };
@@ -0,0 +1 @@
1
+ export * from './emit';
@@ -0,0 +1,40 @@
1
+ export class Emit
2
+ {
3
+ onList: any;
4
+
5
+ constructor()
6
+ {
7
+ this.onList = {};
8
+ }
9
+
10
+ on(eventName: string, cb: any): void
11
+ {
12
+ let aCB: any = this.onList[eventName];
13
+ if (aCB === undefined)
14
+ {
15
+ aCB = [];
16
+ this.onList[eventName] = aCB;
17
+ }
18
+ aCB.push(cb);
19
+ }
20
+
21
+ emit(eventName: string, arg1?: any, arg2?: any, arg3?: any): void
22
+ {
23
+ let aCB: any[] = this.onList[eventName];
24
+ if (aCB !== undefined)
25
+ for (let i: number = 0; i < aCB.length; i++)
26
+ (aCB[i])(arg1, arg2, arg3);
27
+ }
28
+
29
+ off(eventName: string, cb: any): void
30
+ {
31
+ let aCB: any = this.onList[eventName];
32
+ if (aCB !== undefined)
33
+ for (let i: number = 0; i < aCB.length; i++)
34
+ if (aCB[i] === cb)
35
+ {
36
+ aCB.splice(i, 1);
37
+ break;
38
+ }
39
+ }
40
+ }
@@ -73,12 +73,14 @@ export interface SessionUser
73
73
  {
74
74
  id: string;
75
75
  name: string;
76
+ twitterhandle: string;
76
77
  }
77
78
 
78
79
  export interface ActiveUser
79
80
  {
80
81
  id: string;
81
82
  name: string;
83
+ twitterhandle: string;
82
84
  active: number;
83
85
  }
84
86
 
@@ -57,6 +57,8 @@ Util.setCoder({ encoder: new u.TextEncoder(), decoder: new u.TextDecoder('utf-8'
57
57
  Util.setCoder({ encoder: new TextEncoder(), decoder: new TextDecoder('utf-8') });
58
58
  */
59
59
 
60
+ const MaxKeyLength = 128;
61
+
60
62
  export function s2u8(coder: Coder, s: string): Uint8Array
61
63
  {
62
64
  return coder.encoder.encode(s);
@@ -343,13 +345,31 @@ export class BinTrie
343
345
  }
344
346
  return undefined;
345
347
  }
348
+
349
+ forEach(cb: (k: string, v: string) => void)
350
+ {
351
+ let keybuf = new Uint8Array(MaxKeyLength);
352
+ let keylen = 0;
353
+
354
+ let processNode = (len: number, byteOffset: number) => {
355
+ let iOffset = byteOffset >> 2;
356
+ let n = this.i32[iOffset];
357
+ byteOffset += 4;
358
+ for (let j = 0; j < n; j++)
359
+ {
360
+ keybuf[keylen++] = this.u8[byteOffset+j];
361
+ }
362
+ };
363
+ processNode(0, 4);
364
+ }
346
365
  }
347
366
 
348
367
  export interface BinTrieOptions
349
368
  {
350
369
  dedup?: boolean,
370
+ verbose?: boolean,
351
371
  }
352
- let DefaultOptions: BinTrieOptions = { dedup: true };
372
+ let DefaultOptions: BinTrieOptions = { dedup: true, verbose: false };
353
373
 
354
374
  export class BinTrieBuilder
355
375
  {
@@ -607,7 +627,8 @@ export class BinTrieBuilder
607
627
  }
608
628
  });
609
629
 
610
- console.log(`bintrie: total size: ${btb.u8.length}, value table size: ${btb.vtb.u8.length}`);
630
+ if (btb.options.verbose)
631
+ console.log(`bintrie: total size: ${btb.u8.length}, value table size: ${btb.vtb.u8.length}`);
611
632
 
612
633
  return bt;
613
634
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.20",
3
+ "version": "1.0.23",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",