@dra2020/baseclient 1.0.71 → 1.0.75

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 './dataflow';
@@ -0,0 +1,23 @@
1
+ interface UseItem {
2
+ df: DataFlow;
3
+ id?: any;
4
+ }
5
+ export declare class DataFlow {
6
+ usesList: UseItem[];
7
+ constructor();
8
+ id(): any;
9
+ value(): any;
10
+ uses(df: DataFlow): void;
11
+ usesStale(): boolean;
12
+ usesRemember(): void;
13
+ ifcompute(): void;
14
+ compute(): void;
15
+ }
16
+ export declare class DataFlowCallback extends DataFlow {
17
+ _value: any;
18
+ _cb: () => any;
19
+ constructor(cb: () => any);
20
+ id(): any;
21
+ value(): any;
22
+ }
23
+ export {};
package/lib/all/all.ts CHANGED
@@ -25,3 +25,5 @@ import * as CSV from '../csv/all';
25
25
  export { CSV };
26
26
  import * as Colors from '../colors/colors';
27
27
  export { Colors };
28
+ import * as DataFlow from '../dataflow/all';
29
+ export { DataFlow }
package/lib/csv/csv.ts CHANGED
@@ -87,6 +87,10 @@ export class ParseOne
87
87
  this.quote = 0;
88
88
  this.nwhite = 0;
89
89
  }
90
+ else if (this.quote)
91
+ {
92
+ this.tok[this.toklen++] = c;
93
+ }
90
94
  else if (c === Comma || c === Pipe)
91
95
  {
92
96
  this.force = true;
@@ -0,0 +1 @@
1
+ export * from './dataflow';
@@ -0,0 +1,81 @@
1
+ //
2
+ // DataFlow: mechanism for setting up a data-flow dependency graph that gets computed on demand.
3
+ //
4
+ // Semantics are these:
5
+ // 1. The simplest "atomic" DataFlow object just has an id() and a value(). The id() is used to check for exact
6
+ // equivalence when determining if any dependents need to be recomputed. id() and value() might be the same
7
+ // for something that just creates a new whole object when recomputed. In other cases, id() might represent a
8
+ // hash or changestamp/timestamp that is distinct from the value(). The value may or may not be "ready" as well.
9
+ // If the value is not "ready", no dependents can be computed.
10
+ // 2. A DataFlow object can record that it "uses" another DataFlow object. If it does, it can use a set of helper
11
+ // routines to track the state of its dependents. When its dependents are all ready(), it remembers their ids
12
+ // and can later test if they are stale.
13
+ //
14
+ //
15
+
16
+ interface UseItem
17
+ {
18
+ df: DataFlow,
19
+ id?: any,
20
+ }
21
+
22
+ export class DataFlow
23
+ {
24
+ usesList: UseItem[];
25
+
26
+ constructor()
27
+ {
28
+ this.usesList = [];
29
+ }
30
+
31
+ // override in subclass
32
+ id(): any { return null }
33
+ value(): any { return null }
34
+
35
+ uses(df: DataFlow): void
36
+ {
37
+ this.usesList.push({ df: df });
38
+ }
39
+
40
+ usesStale(): boolean
41
+ {
42
+ let isstale = false;
43
+ this.usesList.forEach(ui => { if (ui.id !== ui.df.id()) isstale = true });
44
+ return isstale;
45
+ }
46
+
47
+ usesRemember(): void
48
+ {
49
+ this.usesList.forEach(ui => { ui.id = ui.df.id() });
50
+ }
51
+
52
+ ifcompute(): void
53
+ {
54
+ if (this.usesStale())
55
+ {
56
+ this.usesRemember();
57
+ this.compute();
58
+ }
59
+ }
60
+
61
+ compute(): void
62
+ {
63
+ }
64
+ }
65
+
66
+ // Takes callback that, eventually, returns non-null. The return value is both the value and the id.
67
+ // Once the value returns non-null, the callback is never called again.
68
+ export class DataFlowCallback extends DataFlow
69
+ {
70
+ _value: any;
71
+ _cb: () => any;
72
+
73
+ constructor(cb: () => any)
74
+ {
75
+ super();
76
+ this._cb = cb;
77
+ }
78
+
79
+ id(): any { if (!this._value) this._value = this._cb(); return this._value }
80
+ value(): any { return this.id() }
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.71",
3
+ "version": "1.0.75",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",