@woosh/meep-engine 2.113.12 → 2.113.14
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/build/bundle-worker-image-decoder.js +1 -1
- package/build/meep.cjs +4 -0
- package/build/meep.module.js +4 -0
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +12 -4
- package/src/core/collection/array/typed/array_buffer_copy.d.ts +11 -0
- package/src/core/collection/array/typed/array_buffer_copy.d.ts.map +1 -0
- package/src/core/collection/array/typed/array_buffer_copy.js +55 -0
- package/src/core/collection/table/RowFirstTable.d.ts +42 -27
- package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
- package/src/core/collection/table/RowFirstTable.js +136 -70
- package/src/core/collection/table/deserializeRowFirstTable.d.ts.map +1 -1
- package/src/core/collection/table/deserializeRowFirstTable.js +1 -2
- package/src/core/math/random/randomIntegerBetween.d.ts.map +1 -1
- package/src/core/math/random/randomIntegerBetween.js +3 -0
- package/src/core/model/reactive/model/ReactiveExpression.d.ts.map +1 -1
- package/src/core/model/reactive/model/ReactiveExpression.js +1 -1
- package/src/core/model/reactive/model/ReactiveUnaryExpression.d.ts +5 -1
- package/src/core/model/reactive/model/ReactiveUnaryExpression.d.ts.map +1 -1
- package/src/core/model/reactive/model/ReactiveUnaryExpression.js +4 -0
- package/src/core/model/reactive/model/arithmetic/ReactiveAdd.d.ts +7 -10
- package/src/core/model/reactive/model/arithmetic/ReactiveAdd.d.ts.map +1 -1
- package/src/core/model/reactive/model/arithmetic/ReactiveAdd.js +19 -13
- package/src/core/model/reactive/model/arithmetic/ReactiveDivide.d.ts +7 -9
- package/src/core/model/reactive/model/arithmetic/ReactiveDivide.d.ts.map +1 -1
- package/src/core/model/reactive/model/arithmetic/ReactiveDivide.js +14 -13
- package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.d.ts +7 -10
- package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.d.ts.map +1 -1
- package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.js +19 -13
- package/src/core/model/reactive/model/arithmetic/ReactiveNegate.d.ts +6 -8
- package/src/core/model/reactive/model/arithmetic/ReactiveNegate.d.ts.map +1 -1
- package/src/core/model/reactive/model/arithmetic/ReactiveNegate.js +14 -12
- package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.d.ts +7 -9
- package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.d.ts.map +1 -1
- package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.js +16 -14
- package/src/core/model/reactive/model/comparative/ReactiveEquals.d.ts +7 -10
- package/src/core/model/reactive/model/comparative/ReactiveEquals.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveEquals.js +18 -12
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.d.ts +7 -9
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.js +15 -14
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.d.ts +10 -8
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js +18 -13
- package/src/core/model/reactive/model/comparative/ReactiveLessThan.d.ts +10 -8
- package/src/core/model/reactive/model/comparative/ReactiveLessThan.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveLessThan.js +18 -12
- package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.d.ts +10 -8
- package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.js +18 -12
- package/src/core/model/reactive/model/comparative/ReactiveNotEquals.d.ts +7 -10
- package/src/core/model/reactive/model/comparative/ReactiveNotEquals.d.ts.map +1 -1
- package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +18 -13
- package/src/core/model/reactive/model/logic/ReactiveAnd.d.ts.map +1 -1
- package/src/core/model/reactive/model/logic/ReactiveAnd.js +18 -13
- package/src/core/model/reactive/model/logic/ReactiveNot.d.ts +19 -9
- package/src/core/model/reactive/model/logic/ReactiveNot.d.ts.map +1 -1
- package/src/core/model/reactive/model/logic/ReactiveNot.js +24 -10
- package/src/core/model/reactive/model/logic/ReactiveOr.d.ts +7 -10
- package/src/core/model/reactive/model/logic/ReactiveOr.d.ts.map +1 -1
- package/src/core/model/reactive/model/logic/ReactiveOr.js +18 -13
- package/src/core/model/reactive/model/terminal/ReactiveLiteralBoolean.d.ts +9 -7
- package/src/core/model/reactive/model/terminal/ReactiveLiteralBoolean.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveLiteralBoolean.js +14 -11
- package/src/core/model/reactive/model/terminal/ReactiveLiteralNumber.d.ts +9 -7
- package/src/core/model/reactive/model/terminal/ReactiveLiteralNumber.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +14 -11
- package/src/core/model/reactive/model/terminal/ReactiveLiteralString.d.ts +10 -8
- package/src/core/model/reactive/model/terminal/ReactiveLiteralString.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveLiteralString.js +14 -11
- package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveReference.js +25 -21
- package/src/core/model/reactive/model/util/createRandomReactiveExpression.d.ts +2 -2
- package/src/core/model/reactive/model/util/createRandomReactiveExpression.d.ts.map +1 -1
- package/src/core/model/reactive/model/util/createRandomReactiveExpression.js +41 -29
- package/src/core/model/reactive/trigger/ReactiveTrigger.d.ts.map +1 -1
- package/src/core/model/reactive/trigger/ReactiveTrigger.js +2 -0
- package/src/core/model/stat/LinearModifier.d.ts.map +1 -1
- package/src/core/model/stat/LinearModifier.js +4 -0
- package/src/engine/animation/async/TimeSeries.js +2 -2
- package/src/engine/ecs/fow/FogOfWar.js +1 -1
- package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +1 -1
- package/src/core/model/scheme/Schema.d.ts +0 -38
- package/src/core/model/scheme/Schema.d.ts.map +0 -1
- package/src/core/model/scheme/Schema.js +0 -72
- package/src/core/model/scheme/SchemeRegistry.d.ts +0 -19
- package/src/core/model/scheme/SchemeRegistry.d.ts.map +0 -1
- package/src/core/model/scheme/SchemeRegistry.js +0 -55
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compact binary table storage
|
|
3
|
+
* Very efficient in terms of memory usage and allocation
|
|
4
|
+
* You can think of it as an SQL table but only for numbers
|
|
3
5
|
*/
|
|
4
6
|
export class RowFirstTable {
|
|
5
7
|
/**
|
|
@@ -34,8 +36,12 @@ export class RowFirstTable {
|
|
|
34
36
|
* @type {DataView}
|
|
35
37
|
*/
|
|
36
38
|
dataView: DataView;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @type {{added: Signal}}
|
|
42
|
+
*/
|
|
37
43
|
on: {
|
|
38
|
-
added: Signal
|
|
44
|
+
added: Signal;
|
|
39
45
|
};
|
|
40
46
|
/**
|
|
41
47
|
* @deprecated access directly via spec instead
|
|
@@ -48,19 +54,15 @@ export class RowFirstTable {
|
|
|
48
54
|
*/
|
|
49
55
|
get bytesPerRecord(): number;
|
|
50
56
|
/**
|
|
51
|
-
* @
|
|
57
|
+
* @deprecated use {@link RowFirstTable.spec.readRowMethod} instead
|
|
58
|
+
* @return {function(DataView, number, number[]): void}
|
|
52
59
|
*/
|
|
53
|
-
|
|
60
|
+
get readRowMethod(): (arg0: DataView, arg1: number, arg2: number[]) => void;
|
|
54
61
|
/**
|
|
55
|
-
|
|
56
|
-
* @
|
|
62
|
+
@deprecated use {@link RowFirstTable.spec.writeRowMethod} instead
|
|
63
|
+
* @return {function(DataView, number, number[]): void}
|
|
57
64
|
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @type {function(DataView, number, number[]): void}
|
|
62
|
-
*/
|
|
63
|
-
writeRowMethod: (arg0: DataView, arg1: number, arg2: number[]) => void;
|
|
65
|
+
get writeRowMethod(): (arg0: DataView, arg1: number, arg2: number[]) => void;
|
|
64
66
|
/**
|
|
65
67
|
* NOTE: capacity is set automatically
|
|
66
68
|
* NOTE: length is not set automatically, you have to do that yourself
|
|
@@ -88,31 +90,31 @@ export class RowFirstTable {
|
|
|
88
90
|
resize(rowCount: number): void;
|
|
89
91
|
/**
|
|
90
92
|
*
|
|
91
|
-
* @param {number}
|
|
92
|
-
* @param {number}
|
|
93
|
+
* @param {number} row_index
|
|
94
|
+
* @param {number} column_index
|
|
93
95
|
* @param {number} value
|
|
94
96
|
*/
|
|
95
|
-
writeCellValue(
|
|
97
|
+
writeCellValue(row_index: number, column_index: number, value: number): void;
|
|
96
98
|
/**
|
|
97
99
|
* read a single cell value from the table
|
|
98
|
-
* @param {number}
|
|
99
|
-
* @param {number}
|
|
100
|
+
* @param {number} row_index
|
|
101
|
+
* @param {number} column_index
|
|
100
102
|
* @returns {number}
|
|
101
103
|
*/
|
|
102
|
-
readCellValue(
|
|
104
|
+
readCellValue(row_index: number, column_index: number): number;
|
|
103
105
|
/**
|
|
104
106
|
* Remove rows from the table
|
|
105
107
|
* @param {number} index starting row
|
|
106
|
-
* @param {number}
|
|
108
|
+
* @param {number} row_count number of rows to be removed
|
|
107
109
|
*/
|
|
108
|
-
removeRows(index: number,
|
|
110
|
+
removeRows(index: number, row_count: number): void;
|
|
109
111
|
/**
|
|
110
112
|
* Insert a number of blank rows at the given offset
|
|
111
113
|
* NOTE: doesn't send onAdded signal
|
|
112
114
|
* @param {number} index
|
|
113
|
-
* @param {number}
|
|
115
|
+
* @param {number} row_count
|
|
114
116
|
*/
|
|
115
|
-
insertRows(index: number,
|
|
117
|
+
insertRows(index: number, row_count: number): void;
|
|
116
118
|
/**
|
|
117
119
|
*
|
|
118
120
|
* @param {Array.<number>} values
|
|
@@ -143,17 +145,18 @@ export class RowFirstTable {
|
|
|
143
145
|
*/
|
|
144
146
|
equals(other: RowFirstTable): boolean;
|
|
145
147
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {
|
|
148
|
-
* @param {
|
|
148
|
+
* Read a single row of values from the table
|
|
149
|
+
* @param {number} index
|
|
150
|
+
* @param {number[]} [result] where row values are to be stored
|
|
151
|
+
* @returns {number[]} result
|
|
149
152
|
*/
|
|
150
|
-
|
|
153
|
+
readRow(index: number, result?: number[]): number[];
|
|
151
154
|
/**
|
|
152
|
-
*
|
|
155
|
+
* Write a single row of values
|
|
153
156
|
* @param {number} index
|
|
154
157
|
* @param {number[]} record
|
|
155
158
|
*/
|
|
156
|
-
|
|
159
|
+
writeRow(index: number, record: number[]): void;
|
|
157
160
|
/**
|
|
158
161
|
* Reverse order of rows, row-0 will end up at and previously last row will become the first row etc.
|
|
159
162
|
*/
|
|
@@ -176,6 +179,18 @@ export class RowFirstTable {
|
|
|
176
179
|
* Print the table to console
|
|
177
180
|
*/
|
|
178
181
|
printToConsole(): void;
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated
|
|
184
|
+
*/
|
|
185
|
+
initialize(): void;
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated use {@link RowFirstTable#readRow} instead
|
|
188
|
+
*/
|
|
189
|
+
getRow: (index: number, result?: number[]) => number[];
|
|
190
|
+
/**
|
|
191
|
+
@deprecated use {@link RowFirstTable#writeRow} instead
|
|
192
|
+
*/
|
|
193
|
+
setRow: (index: number, record: number[]) => void;
|
|
179
194
|
}
|
|
180
195
|
import Signal from "../../events/signal/Signal.js";
|
|
181
196
|
//# sourceMappingURL=RowFirstTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AAaA;;;;GAIG;AACH;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EAiDjB;IAzCG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,MAFU,WAAW,CAE4D;IAEjF;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEgB;IAEhC;;;OAGG;IACH,UAFU,QAAQ,CAEqB;IAEvC;;;OAGG;IACH,IAFU;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAOxB;IAIL;;;OAGG;IACH,8BAEC;IAED;;;OAGG;IACH,6BAEC;IAED;;;OAGG;IACH,4BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAED;;;OAGG;IACH,6BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAGD;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA+BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAgDhB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,iBAFW,MAAM,QAchB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,gBACN,MAAM,SACN,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,gBACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,kBAHW,MAAM,aACN,MAAM,QAyBhB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,aACN,MAAM,QAqBhB;IAED;;;;OAIG;IACH,eAHW,MAAO,MAAM,CAAC,GACZ,MAAM,CAiBlB;IAED;;;;OAIG;IACH,eAHW,MAAM,4BA8ChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,QAwBhB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAmBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAmCnB;IAED;;;;;OAKG;IACH,eAJW,MAAM,WACN,MAAM,EAAE,GACN,MAAM,EAAE,CAUpB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,EAAE,QAUlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAetB;IAED;;OAEG;IACH,uBAIC;IAED;;OAEG;IACH,mBAEC;IAGL;;OAEG;IACH,gBAtHe,MAAM,WACN,MAAM,EAAE,KACN,MAAM,EAAE,CAoHK;IAC9B;;OAEG;IACH,gBA1Ge,MAAM,UACN,MAAM,EAAE,UAyGO;CAT7B;mBAvmBkB,+BAA+B"}
|
|
@@ -3,9 +3,18 @@ import { makeArrayBuffer } from "../../binary/makeArrayBuffer.js";
|
|
|
3
3
|
import Signal from "../../events/signal/Signal.js";
|
|
4
4
|
import { max2 } from "../../math/max2.js";
|
|
5
5
|
import { array_copy } from "../array/array_copy.js";
|
|
6
|
+
import { array_buffer_copy } from "../array/typed/array_buffer_copy.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* How much space to reserve in a newly created table, counted in ROWs
|
|
10
|
+
* @type {number}
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_CAPACITY = 8
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Compact binary table storage
|
|
16
|
+
* Very efficient in terms of memory usage and allocation
|
|
17
|
+
* You can think of it as an SQL table but only for numbers
|
|
9
18
|
*/
|
|
10
19
|
export class RowFirstTable {
|
|
11
20
|
/**
|
|
@@ -29,7 +38,7 @@ export class RowFirstTable {
|
|
|
29
38
|
*
|
|
30
39
|
* @type {ArrayBuffer}
|
|
31
40
|
*/
|
|
32
|
-
this.data = makeArrayBuffer(
|
|
41
|
+
this.data = makeArrayBuffer(spec.bytesPerRecord * DEFAULT_CAPACITY, shared_array);
|
|
33
42
|
|
|
34
43
|
/**
|
|
35
44
|
* number of records
|
|
@@ -41,19 +50,25 @@ export class RowFirstTable {
|
|
|
41
50
|
* capacity in number of records
|
|
42
51
|
* @type {number}
|
|
43
52
|
*/
|
|
44
|
-
this.capacity =
|
|
53
|
+
this.capacity = DEFAULT_CAPACITY;
|
|
45
54
|
|
|
46
55
|
/**
|
|
47
56
|
*
|
|
48
57
|
* @type {DataView}
|
|
49
58
|
*/
|
|
50
|
-
this.dataView =
|
|
59
|
+
this.dataView = new DataView(this.data);
|
|
51
60
|
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @type {{added: Signal}}
|
|
64
|
+
*/
|
|
52
65
|
this.on = {
|
|
66
|
+
/**
|
|
67
|
+
* @readonly
|
|
68
|
+
*/
|
|
53
69
|
added: new Signal()
|
|
54
70
|
};
|
|
55
71
|
|
|
56
|
-
this.initialize();
|
|
57
72
|
}
|
|
58
73
|
|
|
59
74
|
/**
|
|
@@ -73,24 +88,22 @@ export class RowFirstTable {
|
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
/**
|
|
76
|
-
* @
|
|
91
|
+
* @deprecated use {@link RowFirstTable.spec.readRowMethod} instead
|
|
92
|
+
* @return {function(DataView, number, number[]): void}
|
|
77
93
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* @type {function(DataView, number, number[]): void}
|
|
84
|
-
*/
|
|
85
|
-
this.readRowMethod = spec.readRowMethod;
|
|
94
|
+
get readRowMethod() {
|
|
95
|
+
return this.spec.readRowMethod;
|
|
96
|
+
}
|
|
86
97
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
/**
|
|
99
|
+
@deprecated use {@link RowFirstTable.spec.writeRowMethod} instead
|
|
100
|
+
* @return {function(DataView, number, number[]): void}
|
|
101
|
+
*/
|
|
102
|
+
get writeRowMethod() {
|
|
103
|
+
return this.spec.writeRowMethod;
|
|
92
104
|
}
|
|
93
105
|
|
|
106
|
+
|
|
94
107
|
/**
|
|
95
108
|
* NOTE: capacity is set automatically
|
|
96
109
|
* NOTE: length is not set automatically, you have to do that yourself
|
|
@@ -109,28 +122,31 @@ export class RowFirstTable {
|
|
|
109
122
|
* @returns {number}
|
|
110
123
|
*/
|
|
111
124
|
hash() {
|
|
112
|
-
// to keep hash calculation fast, do a fixed number evenly spaced taps inside the data table
|
|
113
125
|
|
|
114
126
|
const byteLength = this.data.byteLength;
|
|
127
|
+
const dataView = this.dataView;
|
|
128
|
+
|
|
129
|
+
let result = byteLength;
|
|
130
|
+
|
|
115
131
|
|
|
132
|
+
const uint32_length = byteLength >> 2;
|
|
133
|
+
|
|
134
|
+
// to keep hash calculation fast, do a fixed number evenly spaced taps inside the data table
|
|
116
135
|
const tap_count = 31;
|
|
117
136
|
|
|
118
137
|
const step_size = max2(
|
|
119
|
-
Math.floor(
|
|
138
|
+
Math.floor(uint32_length / tap_count),
|
|
120
139
|
1
|
|
121
140
|
);
|
|
122
141
|
|
|
123
|
-
const step_count = Math.floor(
|
|
124
|
-
|
|
125
|
-
const dataView = this.dataView;
|
|
126
|
-
|
|
127
|
-
let result = byteLength;
|
|
142
|
+
const step_count = Math.floor(uint32_length / step_size);
|
|
128
143
|
|
|
129
144
|
for (let i = 0; i < step_count; i++) {
|
|
130
|
-
const address = i * step_size
|
|
145
|
+
const address = (i * step_size) << 2;
|
|
146
|
+
|
|
147
|
+
const uint32 = dataView.getUint32(address);
|
|
131
148
|
|
|
132
|
-
result = ((result << 5) - result) +
|
|
133
|
-
result |= 0; // Convert to 32bit integer
|
|
149
|
+
result = ((result << 5) - result) + uint32;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
return result;
|
|
@@ -148,7 +164,6 @@ export class RowFirstTable {
|
|
|
148
164
|
return;
|
|
149
165
|
}
|
|
150
166
|
|
|
151
|
-
|
|
152
167
|
const oldData = this.data;
|
|
153
168
|
|
|
154
169
|
const bytesPerRecord = this.spec.bytesPerRecord;
|
|
@@ -168,6 +183,8 @@ export class RowFirstTable {
|
|
|
168
183
|
throw new Error("Generated array was truncated unexpectedly from " + byteSize + " to " + this.data.byteLength);
|
|
169
184
|
}
|
|
170
185
|
|
|
186
|
+
// TODO consider using {@link array_buffer_copy} instead for speed
|
|
187
|
+
|
|
171
188
|
const newArray = new Uint8Array(this.data);
|
|
172
189
|
const oldArray = new Uint8Array(oldData);
|
|
173
190
|
|
|
@@ -214,40 +231,50 @@ export class RowFirstTable {
|
|
|
214
231
|
|
|
215
232
|
/**
|
|
216
233
|
*
|
|
217
|
-
* @param {number}
|
|
218
|
-
* @param {number}
|
|
234
|
+
* @param {number} row_index
|
|
235
|
+
* @param {number} column_index
|
|
219
236
|
* @param {number} value
|
|
220
237
|
*/
|
|
221
|
-
writeCellValue(
|
|
238
|
+
writeCellValue(row_index, column_index, value) {
|
|
222
239
|
const spec = this.spec;
|
|
223
240
|
|
|
241
|
+
assert.lessThan(column_index, spec.getColumnCount(), 'overflow');
|
|
242
|
+
assert.isNonNegativeInteger(column_index, 'column_index');
|
|
243
|
+
|
|
244
|
+
assert.isNonNegativeInteger(row_index, 'row_index');
|
|
245
|
+
|
|
224
246
|
const bytesPerRecord = spec.bytesPerRecord;
|
|
225
247
|
|
|
226
|
-
const rowAddress =
|
|
248
|
+
const rowAddress = row_index * bytesPerRecord;
|
|
227
249
|
|
|
228
250
|
const cellWriters = spec.cellWriters;
|
|
229
251
|
|
|
230
|
-
const cellWriter = cellWriters[
|
|
252
|
+
const cellWriter = cellWriters[column_index];
|
|
231
253
|
|
|
232
254
|
cellWriter(this.dataView, rowAddress, value);
|
|
233
255
|
}
|
|
234
256
|
|
|
235
257
|
/**
|
|
236
258
|
* read a single cell value from the table
|
|
237
|
-
* @param {number}
|
|
238
|
-
* @param {number}
|
|
259
|
+
* @param {number} row_index
|
|
260
|
+
* @param {number} column_index
|
|
239
261
|
* @returns {number}
|
|
240
262
|
*/
|
|
241
|
-
readCellValue(
|
|
263
|
+
readCellValue(row_index, column_index) {
|
|
242
264
|
const spec = this.spec;
|
|
243
265
|
|
|
266
|
+
assert.lessThan(column_index, spec.getColumnCount(), 'overflow');
|
|
267
|
+
assert.isNonNegativeInteger(column_index, 'column_index');
|
|
268
|
+
|
|
269
|
+
assert.isNonNegativeInteger(row_index, 'row_index');
|
|
270
|
+
|
|
244
271
|
const bytesPerRecord = spec.bytesPerRecord;
|
|
245
272
|
|
|
246
|
-
const rowAddress =
|
|
273
|
+
const rowAddress = row_index * bytesPerRecord;
|
|
247
274
|
|
|
248
275
|
const cellReaders = spec.cellReaders;
|
|
249
276
|
|
|
250
|
-
const cellReader = cellReaders[
|
|
277
|
+
const cellReader = cellReaders[column_index];
|
|
251
278
|
|
|
252
279
|
return cellReader(this.dataView, rowAddress);
|
|
253
280
|
}
|
|
@@ -255,12 +282,12 @@ export class RowFirstTable {
|
|
|
255
282
|
/**
|
|
256
283
|
* Remove rows from the table
|
|
257
284
|
* @param {number} index starting row
|
|
258
|
-
* @param {number}
|
|
285
|
+
* @param {number} row_count number of rows to be removed
|
|
259
286
|
*/
|
|
260
|
-
removeRows(index,
|
|
287
|
+
removeRows(index, row_count) {
|
|
261
288
|
|
|
262
289
|
//validate presence to requested rows
|
|
263
|
-
assert.lessThanOrEqual(index +
|
|
290
|
+
assert.lessThanOrEqual(index + row_count, this.length, 'underflow');
|
|
264
291
|
|
|
265
292
|
const data = this.data;
|
|
266
293
|
|
|
@@ -270,13 +297,13 @@ export class RowFirstTable {
|
|
|
270
297
|
|
|
271
298
|
//shift tail of the table forward
|
|
272
299
|
const target = index * bytesPerRecord;
|
|
273
|
-
const start = target +
|
|
300
|
+
const start = target + row_count * bytesPerRecord;
|
|
274
301
|
const end = this.length * bytesPerRecord;
|
|
275
302
|
|
|
276
303
|
array.copyWithin(target, start, end);
|
|
277
304
|
|
|
278
305
|
//adjust new length
|
|
279
|
-
this.length -=
|
|
306
|
+
this.length -= row_count;
|
|
280
307
|
|
|
281
308
|
//resize table
|
|
282
309
|
this.resize(this.length);
|
|
@@ -286,10 +313,10 @@ export class RowFirstTable {
|
|
|
286
313
|
* Insert a number of blank rows at the given offset
|
|
287
314
|
* NOTE: doesn't send onAdded signal
|
|
288
315
|
* @param {number} index
|
|
289
|
-
* @param {number}
|
|
316
|
+
* @param {number} row_count
|
|
290
317
|
*/
|
|
291
|
-
insertRows(index,
|
|
292
|
-
const future_length = this.length +
|
|
318
|
+
insertRows(index, row_count) {
|
|
319
|
+
const future_length = this.length + row_count;
|
|
293
320
|
|
|
294
321
|
this.resize(future_length);
|
|
295
322
|
|
|
@@ -300,7 +327,7 @@ export class RowFirstTable {
|
|
|
300
327
|
const array = new Uint8Array(data);
|
|
301
328
|
|
|
302
329
|
//shift tail of the table forward
|
|
303
|
-
const target = (index +
|
|
330
|
+
const target = (index + row_count) * bytesPerRecord;
|
|
304
331
|
const end = future_length * bytesPerRecord;
|
|
305
332
|
const start = index * bytesPerRecord;
|
|
306
333
|
|
|
@@ -324,7 +351,7 @@ export class RowFirstTable {
|
|
|
324
351
|
|
|
325
352
|
this.length = newRowCount;
|
|
326
353
|
|
|
327
|
-
this.writeRowMethod(this.dataView, this.spec.bytesPerRecord * rowIndex, values);
|
|
354
|
+
this.spec.writeRowMethod(this.dataView, this.spec.bytesPerRecord * rowIndex, values);
|
|
328
355
|
|
|
329
356
|
this.on.added.send2(rowIndex, values);
|
|
330
357
|
|
|
@@ -350,18 +377,26 @@ export class RowFirstTable {
|
|
|
350
377
|
|
|
351
378
|
const bytesPerRecord = spec.bytesPerRecord;
|
|
352
379
|
const dataView = this.dataView;
|
|
353
|
-
const writeRowMethod = this.writeRowMethod;
|
|
380
|
+
const writeRowMethod = this.spec.writeRowMethod;
|
|
354
381
|
|
|
355
382
|
const onAdded = this.on.added;
|
|
356
383
|
|
|
384
|
+
/**
|
|
385
|
+
*
|
|
386
|
+
* @param {number} index
|
|
387
|
+
*/
|
|
357
388
|
function addOneSignaling(index) {
|
|
358
389
|
addOneSilent(index);
|
|
359
390
|
onAdded.send2(index, row);
|
|
360
391
|
}
|
|
361
392
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
393
|
+
/**
|
|
394
|
+
*
|
|
395
|
+
* @param {number} index
|
|
396
|
+
*/
|
|
397
|
+
function addOneSilent(index) {
|
|
398
|
+
valueSupplier(index, row);
|
|
399
|
+
writeRowMethod(dataView, bytesPerRecord * index, row);
|
|
365
400
|
}
|
|
366
401
|
|
|
367
402
|
//depending on whether signal is being listened, pick signaling or silent generator
|
|
@@ -408,6 +443,7 @@ export class RowFirstTable {
|
|
|
408
443
|
* @param {RowFirstTable} other
|
|
409
444
|
*/
|
|
410
445
|
copy(other) {
|
|
446
|
+
|
|
411
447
|
// check that the spec is equivalent
|
|
412
448
|
if (!this.spec.equals(other.spec)) {
|
|
413
449
|
throw new Error('Different table specs');
|
|
@@ -419,14 +455,10 @@ export class RowFirstTable {
|
|
|
419
455
|
|
|
420
456
|
this.length = other.length;
|
|
421
457
|
|
|
422
|
-
const target = new Uint8Array(this.data);
|
|
423
|
-
const source = new Uint8Array(other.data);
|
|
424
|
-
|
|
425
458
|
// copy data
|
|
426
459
|
const data_byte_count = other.spec.bytesPerRecord * record_count;
|
|
427
|
-
target.set(source.slice(0, data_byte_count));
|
|
428
460
|
|
|
429
|
-
|
|
461
|
+
array_buffer_copy(other.data, 0, this.data, 0, data_byte_count);
|
|
430
462
|
}
|
|
431
463
|
|
|
432
464
|
/**
|
|
@@ -434,6 +466,16 @@ export class RowFirstTable {
|
|
|
434
466
|
* @returns {boolean}
|
|
435
467
|
*/
|
|
436
468
|
equals(other) {
|
|
469
|
+
if (other === this) {
|
|
470
|
+
// shortcut
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (other === undefined || other === null) {
|
|
475
|
+
// this should not generally not happen
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
|
|
437
479
|
if (!this.spec.equals(other.spec)) {
|
|
438
480
|
return false;
|
|
439
481
|
}
|
|
@@ -459,25 +501,34 @@ export class RowFirstTable {
|
|
|
459
501
|
}
|
|
460
502
|
|
|
461
503
|
/**
|
|
462
|
-
*
|
|
463
|
-
* @param {
|
|
464
|
-
* @param {
|
|
504
|
+
* Read a single row of values from the table
|
|
505
|
+
* @param {number} index
|
|
506
|
+
* @param {number[]} [result] where row values are to be stored
|
|
507
|
+
* @returns {number[]} result
|
|
465
508
|
*/
|
|
466
|
-
|
|
509
|
+
readRow(index, result = []) {
|
|
467
510
|
assert.isNonNegativeInteger(index, 'index');
|
|
468
511
|
|
|
469
|
-
|
|
512
|
+
const spec = this.spec;
|
|
513
|
+
|
|
514
|
+
spec.readRowMethod(this.dataView, spec.bytesPerRecord * index, result);
|
|
515
|
+
|
|
516
|
+
return result;
|
|
470
517
|
}
|
|
471
518
|
|
|
472
519
|
/**
|
|
473
|
-
*
|
|
520
|
+
* Write a single row of values
|
|
474
521
|
* @param {number} index
|
|
475
522
|
* @param {number[]} record
|
|
476
523
|
*/
|
|
477
|
-
|
|
524
|
+
writeRow(index, record) {
|
|
478
525
|
assert.isNonNegativeInteger(index, 'index');
|
|
479
526
|
|
|
480
|
-
|
|
527
|
+
const spec = this.spec;
|
|
528
|
+
|
|
529
|
+
assert.greaterThanOrEqual(record.length, spec.getColumnCount(), 'input record length is too small');
|
|
530
|
+
|
|
531
|
+
spec.writeRowMethod(this.dataView, spec.bytesPerRecord * index, record);
|
|
481
532
|
}
|
|
482
533
|
|
|
483
534
|
/**
|
|
@@ -499,8 +550,8 @@ export class RowFirstTable {
|
|
|
499
550
|
|
|
500
551
|
const last_row_index = length - 1;
|
|
501
552
|
|
|
502
|
-
|
|
503
553
|
const traversal_limit = last_row_index >>> 1;
|
|
554
|
+
|
|
504
555
|
for (let i = 0; i <= traversal_limit; i++) {
|
|
505
556
|
const address = i * bpr;
|
|
506
557
|
array_copy(wrapper, address, copy_buffer, 0, bpr);
|
|
@@ -539,9 +590,8 @@ export class RowFirstTable {
|
|
|
539
590
|
const result = [];
|
|
540
591
|
|
|
541
592
|
for (let i = 0; i < this.length; i++) {
|
|
542
|
-
const row = [];
|
|
543
593
|
|
|
544
|
-
this.
|
|
594
|
+
const row = this.readRow(i);
|
|
545
595
|
|
|
546
596
|
result.push(row);
|
|
547
597
|
}
|
|
@@ -558,4 +608,20 @@ export class RowFirstTable {
|
|
|
558
608
|
|
|
559
609
|
console.table(rows);
|
|
560
610
|
}
|
|
561
|
-
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* @deprecated
|
|
614
|
+
*/
|
|
615
|
+
initialize() {
|
|
616
|
+
console.warn('deprecated, no longer serves any purpose. Table no longer requires initialization')
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* @deprecated use {@link RowFirstTable#readRow} instead
|
|
622
|
+
*/
|
|
623
|
+
RowFirstTable.prototype.getRow = RowFirstTable.prototype.readRow;
|
|
624
|
+
/**
|
|
625
|
+
@deprecated use {@link RowFirstTable#writeRow} instead
|
|
626
|
+
*/
|
|
627
|
+
RowFirstTable.prototype.setRow = RowFirstTable.prototype.writeRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializeRowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/deserializeRowFirstTable.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"deserializeRowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/deserializeRowFirstTable.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,2FAoCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
|
|
2
1
|
import { computeDataTypeByIndex } from "../../binary/type/computeDataTypeByIndex.js";
|
|
2
|
+
import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -42,7 +42,6 @@ function deserializeRowFirstTable(buffer, table) {
|
|
|
42
42
|
table.data = data.buffer;
|
|
43
43
|
table.dataView = new DataView(table.data);
|
|
44
44
|
|
|
45
|
-
table.initialize();
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export { deserializeRowFirstTable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomIntegerBetween.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/random/randomIntegerBetween.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4DAJW,MAAM,OACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"randomIntegerBetween.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/random/randomIntegerBetween.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4DAJW,MAAM,OACN,MAAM,GACJ,MAAM,CAclB"}
|
|
@@ -15,5 +15,8 @@ export function randomIntegerBetween(random, min, max) {
|
|
|
15
15
|
|
|
16
16
|
const roll = random();
|
|
17
17
|
|
|
18
|
+
assert.greaterThanOrEqual(roll, 0, 'random should return value between 0 and 1');
|
|
19
|
+
assert.lessThanOrEqual(roll, 1, 'random should return value between 0 and 1');
|
|
20
|
+
|
|
18
21
|
return Math.round(roll * span) + min;
|
|
19
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactiveExpression.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/reactive/model/ReactiveExpression.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IAEQ,0DAA6B;IAGjC,uBAEC;IAED,cAEC;IAED;;;;OAIG;IACH,wCAFa,OAAO,CAQnB;IAED;;;OAGG;IACH,UAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,YAFa,CAAC,GAAC,OAAO,GAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"ReactiveExpression.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/reactive/model/ReactiveExpression.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IAEQ,0DAA6B;IAGjC,uBAEC;IAED,cAEC;IAED;;;;OAIG;IACH,wCAFa,OAAO,CAQnB;IAED;;;OAGG;IACH,UAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,YAFa,CAAC,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM,CAInC;IAED;;;;OAIG;IACH,4CAEC;IAED;;;OAGG;IACH,mBAFY,MAAM,CAQjB;IAED;;;OAGG;IACH,iCAIC;IAED;;;;OAIG;IACH,sBAFa,OAAO,GAAC,MAAM,GAAC,MAAM,CAIjC;IAGL,cAAqC;IAErC;;;OAGG;IACH,+BAFU,OAAO,CAEgC;CARhD;mBA/FkB,kCAAkC"}
|
|
@@ -30,7 +30,11 @@ export class ReactiveUnaryExpression<T, R> extends ReactiveExpression<any> {
|
|
|
30
30
|
*/
|
|
31
31
|
hash(): number;
|
|
32
32
|
getValue(): void;
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @readonly
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
readonly isUnaryExpression: boolean;
|
|
34
38
|
}
|
|
35
39
|
import { ReactiveExpression } from "./ReactiveExpression.js";
|
|
36
40
|
//# sourceMappingURL=ReactiveUnaryExpression.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactiveUnaryExpression.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/reactive/model/ReactiveUnaryExpression.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI,cASC;IANG;;;OAGG;IACH,QAFU,mBAAmB,CAAC,CAAC,CAEb;IAItB,uBAMC;IAED,qBAIC;IAED,2CAIC;IAED,2BAMC;IAED,mBAIC;IAED;;OAEG;IACH,kCAEC;IAED,0BAIC;IAED;;;;OAIG;IACH,wCAFa,OAAO,CAOnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED,iBAEC;IAGL,
|
|
1
|
+
{"version":3,"file":"ReactiveUnaryExpression.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/reactive/model/ReactiveUnaryExpression.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI,cASC;IANG;;;OAGG;IACH,QAFU,mBAAmB,CAAC,CAAC,CAEb;IAItB,uBAMC;IAED,qBAIC;IAED,2CAIC;IAED,2BAMC;IAED,mBAIC;IAED;;OAEG;IACH,kCAEC;IAED,0BAIC;IAED;;;;OAIG;IACH,wCAFa,OAAO,CAOnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED,iBAEC;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAEkC;CANlD;mCAvFkC,yBAAyB"}
|