@woosh/meep-engine 2.113.11 → 2.113.13

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/meep.cjs CHANGED
@@ -248,6 +248,12 @@ class InMemoryDescriptor extends BaseDescription {
248
248
  }
249
249
  }
250
250
 
251
+ /**
252
+ * @template T
253
+ * @param {T} a
254
+ * @param {T} b
255
+ * @param {string} [m]
256
+ */
251
257
  function equal(a, b, m) {
252
258
  if (a !== b) {
253
259
  const details = `${a} !== ${b}`;
@@ -257,10 +263,21 @@ function equal(a, b, m) {
257
263
  }
258
264
  }
259
265
 
266
+ /**
267
+ * @template T
268
+ * @param {T} a
269
+ * @param {T} b
270
+ * @param {string} [m]
271
+ */
260
272
  function notEqual(a, b, m) {
261
273
  assert(a !== b, m); // eslint-disable-line eqeqeq
262
274
  }
263
275
 
276
+ /**
277
+ *
278
+ * @param {boolean} t
279
+ * @param {string} [m]
280
+ */
264
281
  function notOk(t, m) {
265
282
  assert(!t, m);
266
283
  }
@@ -274,6 +291,11 @@ function notOk(t, m) {
274
291
  function logicalEquals(a, b, m) {
275
292
  }
276
293
 
294
+ /**
295
+ *
296
+ * @param {boolean} t
297
+ * @param {string} [m]
298
+ */
277
299
  function assert(t, m) {
278
300
  if (!t) {
279
301
  throw new Error(m || 'AssertionError')
@@ -246,6 +246,12 @@ class InMemoryDescriptor extends BaseDescription {
246
246
  }
247
247
  }
248
248
 
249
+ /**
250
+ * @template T
251
+ * @param {T} a
252
+ * @param {T} b
253
+ * @param {string} [m]
254
+ */
249
255
  function equal(a, b, m) {
250
256
  if (a !== b) {
251
257
  const details = `${a} !== ${b}`;
@@ -255,10 +261,21 @@ function equal(a, b, m) {
255
261
  }
256
262
  }
257
263
 
264
+ /**
265
+ * @template T
266
+ * @param {T} a
267
+ * @param {T} b
268
+ * @param {string} [m]
269
+ */
258
270
  function notEqual(a, b, m) {
259
271
  assert(a !== b, m); // eslint-disable-line eqeqeq
260
272
  }
261
273
 
274
+ /**
275
+ *
276
+ * @param {boolean} t
277
+ * @param {string} [m]
278
+ */
262
279
  function notOk(t, m) {
263
280
  assert(!t, m);
264
281
  }
@@ -272,6 +289,11 @@ function notOk(t, m) {
272
289
  function logicalEquals(a, b, m) {
273
290
  }
274
291
 
292
+ /**
293
+ *
294
+ * @param {boolean} t
295
+ * @param {string} [m]
296
+ */
275
297
  function assert(t, m) {
276
298
  if (!t) {
277
299
  throw new Error(m || 'AssertionError')
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.113.11",
8
+ "version": "2.113.13",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,4 +1,9 @@
1
- export function assert(t: any, m: any): void;
1
+ /**
2
+ *
3
+ * @param {boolean} t
4
+ * @param {string} [m]
5
+ */
6
+ export function assert(t: boolean, m?: string): void;
2
7
  export namespace assert {
3
8
  /**
4
9
  * @template T
@@ -121,9 +126,26 @@ export namespace assert {
121
126
  */
122
127
  export function that<T>(value: T, name: string, matcher: Matcher<T>): void;
123
128
  }
124
- declare function notEqual(a: any, b: any, m: any): void;
125
- declare function notOk(t: any, m: any): void;
126
- declare function equal(a: any, b: any, m: any): void;
129
+ /**
130
+ * @template T
131
+ * @param {T} a
132
+ * @param {T} b
133
+ * @param {string} [m]
134
+ */
135
+ declare function notEqual<T>(a: T, b: T, m?: string): void;
136
+ /**
137
+ *
138
+ * @param {boolean} t
139
+ * @param {string} [m]
140
+ */
141
+ declare function notOk(t: boolean, m?: string): void;
142
+ /**
143
+ * @template T
144
+ * @param {T} a
145
+ * @param {T} b
146
+ * @param {string} [m]
147
+ */
148
+ declare function equal<T>(a: T, b: T, m?: string): void;
127
149
  /**
128
150
  *
129
151
  * @param {object} a
@@ -1 +1 @@
1
- {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"AA+BA,6CAIC;;IAsJD;;;;;OAKG;IACH,kEAQC;;;;;;;;;;;;;;;IAmBD;;;;;;OAMG;IACH,uGAGC;IAGD;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,4DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,sEAMC;IAED;;;;OAIG;IACH,4DAKC;IAED;;;;OAIG;IACH,4GAKC;IAGD;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,wDAIC;IAED;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,2DAIC;IAED;;;;OAIG;IACH,mEAIC;IAED;;;;;OAKG;IACH,2EAgBC;;AA/ZD,wDAEC;AAED,6CAEC;AAfD,qDAOC;AAUD;;;;;GAKG;AACH,kCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAIhB;AAQD;;;;;GAKG;AACH,gCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,uCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AA5CD;;;;;GAKG;AACH,6BAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,oCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAKD;;;;;GAKG;AACH,0CAHW,MAAM,cACN,MAAM,QAehB;AAED;;;;;GAKG;AACH,iEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,mEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,+IAFW,MAAM,QAMhB"}
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,0BAHW,OAAO,MACP,MAAM,QAMhB;;IAsJD;;;;;OAKG;IACH,kEAQC;;;;;;;;;;;;;;;IAmBD;;;;;;OAMG;IACH,uGAGC;IAGD;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,4DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,sEAMC;IAED;;;;OAIG;IACH,4DAKC;IAED;;;;OAIG;IACH,4GAKC;IAGD;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,wDAIC;IAED;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,2DAIC;IAED;;;;OAIG;IACH,mEAIC;IAED;;;;;OAKG;IACH,2EAgBC;;AA/aD;;;;;GAKG;AACH,6CAFW,MAAM,QAIhB;AAED;;;;GAIG;AACH,0BAHW,OAAO,MACP,MAAM,QAIhB;AAhCD;;;;;GAKG;AACH,0CAFW,MAAM,QAShB;AAqBD;;;;;GAKG;AACH,kCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAIhB;AAaD;;;;;GAKG;AACH,gCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,uCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AA5CD;;;;;GAKG;AACH,6BAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,oCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAKD;;;;;GAKG;AACH,0CAHW,MAAM,cACN,MAAM,QAehB;AAED;;;;;GAKG;AACH,iEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,mEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,+IAFW,MAAM,QAMhB"}
@@ -2,6 +2,12 @@ import { isArrayEqualStrict } from "./collection/array/isArrayEqualStrict.js";
2
2
  import { isTypedArray } from "./collection/array/typed/isTypedArray.js";
3
3
  import { InMemoryDescriptor } from "./debug/InMemoryDescriptor.js";
4
4
 
5
+ /**
6
+ * @template T
7
+ * @param {T} a
8
+ * @param {T} b
9
+ * @param {string} [m]
10
+ */
5
11
  function equal(a, b, m) {
6
12
  if (a !== b) {
7
13
  const details = `${a} !== ${b}`;
@@ -11,10 +17,21 @@ function equal(a, b, m) {
11
17
  }
12
18
  }
13
19
 
20
+ /**
21
+ * @template T
22
+ * @param {T} a
23
+ * @param {T} b
24
+ * @param {string} [m]
25
+ */
14
26
  function notEqual(a, b, m) {
15
27
  assert(a !== b, m) // eslint-disable-line eqeqeq
16
28
  }
17
29
 
30
+ /**
31
+ *
32
+ * @param {boolean} t
33
+ * @param {string} [m]
34
+ */
18
35
  function notOk(t, m) {
19
36
  assert(!t, m)
20
37
  }
@@ -29,6 +46,11 @@ function logicalEquals(a, b, m) {
29
46
  assert.ok(a.equals(b), m);
30
47
  }
31
48
 
49
+ /**
50
+ *
51
+ * @param {boolean} t
52
+ * @param {string} [m]
53
+ */
32
54
  function assert(t, m) {
33
55
  if (!t) {
34
56
  throw new Error(m || 'AssertionError')
@@ -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<any, any, any, any, any, any, any, any>;
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
- * @private
52
- */
53
- private initialize;
54
- /**
55
- *
56
- * @type {function(DataView, number, number[]): void}
57
+ * @deprecated use {@link RowFirstTable.spec.readRowMethod} instead
58
+ * @return {function(DataView, number, number[]): void}
57
59
  */
58
- readRowMethod: (arg0: DataView, arg1: number, arg2: number[]) => void;
60
+ get readRowMethod(): (arg0: DataView, arg1: number, arg2: number[]) => void;
59
61
  /**
60
- *
61
- * @type {function(DataView, number, number[]): void}
62
+ @deprecated use {@link RowFirstTable.spec.writeRowMethod} instead
63
+ * @return {function(DataView, number, number[]): void}
62
64
  */
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} rowIndex
92
- * @param {number} columnIndex
93
+ * @param {number} row_index
94
+ * @param {number} column_index
93
95
  * @param {number} value
94
96
  */
95
- writeCellValue(rowIndex: number, columnIndex: number, value: number): void;
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} rowIndex
99
- * @param {number} columnIndex
100
+ * @param {number} row_index
101
+ * @param {number} column_index
100
102
  * @returns {number}
101
103
  */
102
- readCellValue(rowIndex: number, columnIndex: number): number;
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} rowCount number of rows to be removed
108
+ * @param {number} row_count number of rows to be removed
107
109
  */
108
- removeRows(index: number, rowCount: number): void;
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} rowCount
115
+ * @param {number} row_count
114
116
  */
115
- insertRows(index: number, rowCount: number): void;
117
+ insertRows(index: number, row_count: number): void;
116
118
  /**
117
119
  *
118
120
  * @param {Array.<number>} values
@@ -144,16 +146,17 @@ export class RowFirstTable {
144
146
  equals(other: RowFirstTable): boolean;
145
147
  /**
146
148
  *
147
- * @param {int} index
148
- * @param {Array} result where row values are to be stored
149
+ * @param {number} index
150
+ * @param {number[]} [result] where row values are to be stored
151
+ * @returns {number[]} result
149
152
  */
150
- getRow(index: int, result: any[]): void;
153
+ readRow(index: number, result?: number[]): number[];
151
154
  /**
152
155
  *
153
156
  * @param {number} index
154
157
  * @param {number[]} record
155
158
  */
156
- setRow(index: number, record: number[]): void;
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":"AAMA;;GAEG;AACH;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EA2CjB;IAnCG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,MAFU,WAAW,CAEuB;IAE5C;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,UAFU,QAAQ,CAEE;IAEpB;;MAEC;IAKL;;;OAGG;IACH,8BAEC;IAED;;;OAGG;IACH,6BAEC;IAED;;OAEG;IACH,mBAcC;IAXG;;;OAGG;IACH,sBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEb;IAEvC;;;OAGG;IACH,uBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEX;IAG7C;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA4BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QA+ChB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,iBAFW,MAAM,QAchB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,eACN,MAAM,SACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAclB;IAED;;;;OAIG;IACH,kBAHW,MAAM,YACN,MAAM,QAyBhB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,YACN,MAAM,QAqBhB;IAED;;;;OAIG;IACH,eAHW,MAAO,MAAM,CAAC,GACZ,MAAM,CAiBlB;IAED;;;;OAIG;IACH,eAHW,MAAM,4BAsChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,QAwBhB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAsBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAyBnB;IAED;;;;OAIG;IACH,wCAIC;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,EAAE,QAMlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAgBtB;IAED;;OAEG;IACH,uBAIC;CACJ;mBA9iBkB,+BAA+B"}
1
+ {"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AAYA;;;;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,QA8ChB;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,4BAsChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,QAwBhB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAqBvB;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,QAQlB;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,gBApHe,MAAM,WACN,MAAM,EAAE,KACN,MAAM,EAAE,CAkHK;IAC9B;;OAEG;IACH,gBAxGe,MAAM,UACN,MAAM,EAAE,UAuGO;CAT7B;mBA5lBkB,+BAA+B"}
@@ -4,8 +4,16 @@ 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
6
 
7
+ /**
8
+ * How much space to reserve in a newly created table, counted in ROWs
9
+ * @type {number}
10
+ */
11
+ const DEFAULT_CAPACITY = 8
12
+
7
13
  /**
8
14
  * Compact binary table storage
15
+ * Very efficient in terms of memory usage and allocation
16
+ * You can think of it as an SQL table but only for numbers
9
17
  */
10
18
  export class RowFirstTable {
11
19
  /**
@@ -29,7 +37,7 @@ export class RowFirstTable {
29
37
  *
30
38
  * @type {ArrayBuffer}
31
39
  */
32
- this.data = makeArrayBuffer(0, shared_array);
40
+ this.data = makeArrayBuffer(spec.bytesPerRecord * DEFAULT_CAPACITY, shared_array);
33
41
 
34
42
  /**
35
43
  * number of records
@@ -41,19 +49,25 @@ export class RowFirstTable {
41
49
  * capacity in number of records
42
50
  * @type {number}
43
51
  */
44
- this.capacity = 0;
52
+ this.capacity = DEFAULT_CAPACITY;
45
53
 
46
54
  /**
47
55
  *
48
56
  * @type {DataView}
49
57
  */
50
- this.dataView = null;
58
+ this.dataView = new DataView(this.data);
51
59
 
60
+ /**
61
+ *
62
+ * @type {{added: Signal}}
63
+ */
52
64
  this.on = {
65
+ /**
66
+ * @readonly
67
+ */
53
68
  added: new Signal()
54
69
  };
55
70
 
56
- this.initialize();
57
71
  }
58
72
 
59
73
  /**
@@ -73,24 +87,22 @@ export class RowFirstTable {
73
87
  }
74
88
 
75
89
  /**
76
- * @private
90
+ * @deprecated use {@link RowFirstTable.spec.readRowMethod} instead
91
+ * @return {function(DataView, number, number[]): void}
77
92
  */
78
- initialize() {
79
- const spec = this.spec;
80
-
81
- /**
82
- *
83
- * @type {function(DataView, number, number[]): void}
84
- */
85
- this.readRowMethod = spec.readRowMethod;
93
+ get readRowMethod() {
94
+ return this.spec.readRowMethod;
95
+ }
86
96
 
87
- /**
88
- *
89
- * @type {function(DataView, number, number[]): void}
90
- */
91
- this.writeRowMethod = spec.writeRowMethod;
97
+ /**
98
+ @deprecated use {@link RowFirstTable.spec.writeRowMethod} instead
99
+ * @return {function(DataView, number, number[]): void}
100
+ */
101
+ get writeRowMethod() {
102
+ return this.spec.writeRowMethod;
92
103
  }
93
104
 
105
+
94
106
  /**
95
107
  * NOTE: capacity is set automatically
96
108
  * NOTE: length is not set automatically, you have to do that yourself
@@ -109,29 +121,32 @@ export class RowFirstTable {
109
121
  * @returns {number}
110
122
  */
111
123
  hash() {
112
- // to keep hash calculation fast, do a fixed number evenly spaced taps inside the data table
113
124
 
114
125
  const byteLength = this.data.byteLength;
126
+ const dataView = this.dataView;
115
127
 
116
- const tap_count = 31;
128
+ let result = byteLength;
117
129
 
118
- const step_size = max2(
119
- Math.floor(byteLength / (tap_count * 4)),
120
- 1
121
- );
122
130
 
123
- const step_count = Math.floor(byteLength / step_size);
131
+ const uint32_length = byteLength >> 2;
124
132
 
125
- const dataView = this.dataView;
133
+ // to keep hash calculation fast, do a fixed number evenly spaced taps inside the data table
134
+ const tap_count = 31;
126
135
 
127
- let result = byteLength;
136
+ const step_size = max2(
137
+ Math.floor(uint32_length / tap_count ),
138
+ 1
139
+ );
128
140
 
129
- for (let i = 0; i < step_count; i++) {
130
- const address = i * step_size * 4;
141
+ const step_count = Math.floor(uint32_length / step_size);
131
142
 
132
- result = ((result << 5) - result) + dataView.getUint32(address);
133
- result |= 0; // Convert to 32bit integer
134
- }
143
+ for (let i = 0; i < step_count; i++) {
144
+ const address = (i * step_size) << 2;
145
+
146
+ const uint32 = dataView.getUint32(address);
147
+
148
+ result = ((result << 5) - result) + uint32;
149
+ }
135
150
 
136
151
  return result;
137
152
  }
@@ -148,7 +163,6 @@ export class RowFirstTable {
148
163
  return;
149
164
  }
150
165
 
151
-
152
166
  const oldData = this.data;
153
167
 
154
168
  const bytesPerRecord = this.spec.bytesPerRecord;
@@ -214,40 +228,50 @@ export class RowFirstTable {
214
228
 
215
229
  /**
216
230
  *
217
- * @param {number} rowIndex
218
- * @param {number} columnIndex
231
+ * @param {number} row_index
232
+ * @param {number} column_index
219
233
  * @param {number} value
220
234
  */
221
- writeCellValue(rowIndex, columnIndex, value) {
235
+ writeCellValue(row_index, column_index, value) {
222
236
  const spec = this.spec;
223
237
 
238
+ assert.lessThan(column_index, spec.getColumnCount(), 'overflow');
239
+ assert.isNonNegativeInteger(column_index, 'column_index');
240
+
241
+ assert.isNonNegativeInteger(row_index, 'row_index');
242
+
224
243
  const bytesPerRecord = spec.bytesPerRecord;
225
244
 
226
- const rowAddress = rowIndex * bytesPerRecord;
245
+ const rowAddress = row_index * bytesPerRecord;
227
246
 
228
247
  const cellWriters = spec.cellWriters;
229
248
 
230
- const cellWriter = cellWriters[columnIndex];
249
+ const cellWriter = cellWriters[column_index];
231
250
 
232
251
  cellWriter(this.dataView, rowAddress, value);
233
252
  }
234
253
 
235
254
  /**
236
255
  * read a single cell value from the table
237
- * @param {number} rowIndex
238
- * @param {number} columnIndex
256
+ * @param {number} row_index
257
+ * @param {number} column_index
239
258
  * @returns {number}
240
259
  */
241
- readCellValue(rowIndex, columnIndex) {
260
+ readCellValue(row_index, column_index) {
242
261
  const spec = this.spec;
243
262
 
263
+ assert.lessThan(column_index, spec.getColumnCount(), 'overflow');
264
+ assert.isNonNegativeInteger(column_index, 'column_index');
265
+
266
+ assert.isNonNegativeInteger(row_index, 'row_index');
267
+
244
268
  const bytesPerRecord = spec.bytesPerRecord;
245
269
 
246
- const rowAddress = rowIndex * bytesPerRecord;
270
+ const rowAddress = row_index * bytesPerRecord;
247
271
 
248
272
  const cellReaders = spec.cellReaders;
249
273
 
250
- const cellReader = cellReaders[columnIndex];
274
+ const cellReader = cellReaders[column_index];
251
275
 
252
276
  return cellReader(this.dataView, rowAddress);
253
277
  }
@@ -255,12 +279,12 @@ export class RowFirstTable {
255
279
  /**
256
280
  * Remove rows from the table
257
281
  * @param {number} index starting row
258
- * @param {number} rowCount number of rows to be removed
282
+ * @param {number} row_count number of rows to be removed
259
283
  */
260
- removeRows(index, rowCount) {
284
+ removeRows(index, row_count) {
261
285
 
262
286
  //validate presence to requested rows
263
- assert.lessThanOrEqual(index + rowCount, this.length, 'underflow');
287
+ assert.lessThanOrEqual(index + row_count, this.length, 'underflow');
264
288
 
265
289
  const data = this.data;
266
290
 
@@ -270,13 +294,13 @@ export class RowFirstTable {
270
294
 
271
295
  //shift tail of the table forward
272
296
  const target = index * bytesPerRecord;
273
- const start = target + rowCount * bytesPerRecord;
297
+ const start = target + row_count * bytesPerRecord;
274
298
  const end = this.length * bytesPerRecord;
275
299
 
276
300
  array.copyWithin(target, start, end);
277
301
 
278
302
  //adjust new length
279
- this.length -= rowCount;
303
+ this.length -= row_count;
280
304
 
281
305
  //resize table
282
306
  this.resize(this.length);
@@ -286,10 +310,10 @@ export class RowFirstTable {
286
310
  * Insert a number of blank rows at the given offset
287
311
  * NOTE: doesn't send onAdded signal
288
312
  * @param {number} index
289
- * @param {number} rowCount
313
+ * @param {number} row_count
290
314
  */
291
- insertRows(index, rowCount) {
292
- const future_length = this.length + rowCount;
315
+ insertRows(index, row_count) {
316
+ const future_length = this.length + row_count;
293
317
 
294
318
  this.resize(future_length);
295
319
 
@@ -300,7 +324,7 @@ export class RowFirstTable {
300
324
  const array = new Uint8Array(data);
301
325
 
302
326
  //shift tail of the table forward
303
- const target = (index + rowCount) * bytesPerRecord;
327
+ const target = (index + row_count) * bytesPerRecord;
304
328
  const end = future_length * bytesPerRecord;
305
329
  const start = index * bytesPerRecord;
306
330
 
@@ -324,7 +348,7 @@ export class RowFirstTable {
324
348
 
325
349
  this.length = newRowCount;
326
350
 
327
- this.writeRowMethod(this.dataView, this.spec.bytesPerRecord * rowIndex, values);
351
+ this.spec.writeRowMethod(this.dataView, this.spec.bytesPerRecord * rowIndex, values);
328
352
 
329
353
  this.on.added.send2(rowIndex, values);
330
354
 
@@ -350,7 +374,7 @@ export class RowFirstTable {
350
374
 
351
375
  const bytesPerRecord = spec.bytesPerRecord;
352
376
  const dataView = this.dataView;
353
- const writeRowMethod = this.writeRowMethod;
377
+ const writeRowMethod = this.spec.writeRowMethod;
354
378
 
355
379
  const onAdded = this.on.added;
356
380
 
@@ -408,6 +432,7 @@ export class RowFirstTable {
408
432
  * @param {RowFirstTable} other
409
433
  */
410
434
  copy(other) {
435
+
411
436
  // check that the spec is equivalent
412
437
  if (!this.spec.equals(other.spec)) {
413
438
  throw new Error('Different table specs');
@@ -425,8 +450,6 @@ export class RowFirstTable {
425
450
  // copy data
426
451
  const data_byte_count = other.spec.bytesPerRecord * record_count;
427
452
  target.set(source.slice(0, data_byte_count));
428
-
429
- // TODO consider if we should invoke onAdded signal
430
453
  }
431
454
 
432
455
  /**
@@ -434,6 +457,16 @@ export class RowFirstTable {
434
457
  * @returns {boolean}
435
458
  */
436
459
  equals(other) {
460
+ if (other === this) {
461
+ // shortcut
462
+ return true;
463
+ }
464
+
465
+ if (other === undefined || other === null) {
466
+ // this should not generally not happen
467
+ return false;
468
+ }
469
+
437
470
  if (!this.spec.equals(other.spec)) {
438
471
  return false;
439
472
  }
@@ -460,13 +493,18 @@ export class RowFirstTable {
460
493
 
461
494
  /**
462
495
  *
463
- * @param {int} index
464
- * @param {Array} result where row values are to be stored
496
+ * @param {number} index
497
+ * @param {number[]} [result] where row values are to be stored
498
+ * @returns {number[]} result
465
499
  */
466
- getRow(index, result) {
500
+ readRow(index, result = []) {
467
501
  assert.isNonNegativeInteger(index, 'index');
468
502
 
469
- this.readRowMethod(this.dataView, this.spec.bytesPerRecord * index, result);
503
+ const spec = this.spec;
504
+
505
+ spec.readRowMethod(this.dataView, spec.bytesPerRecord * index, result);
506
+
507
+ return result;
470
508
  }
471
509
 
472
510
  /**
@@ -474,10 +512,12 @@ export class RowFirstTable {
474
512
  * @param {number} index
475
513
  * @param {number[]} record
476
514
  */
477
- setRow(index, record) {
515
+ writeRow(index, record) {
478
516
  assert.isNonNegativeInteger(index, 'index');
479
517
 
480
- this.writeRowMethod(this.dataView, this.spec.bytesPerRecord * index, record);
518
+ const spec = this.spec;
519
+
520
+ spec.writeRowMethod(this.dataView, spec.bytesPerRecord * index, record);
481
521
  }
482
522
 
483
523
  /**
@@ -539,9 +579,8 @@ export class RowFirstTable {
539
579
  const result = [];
540
580
 
541
581
  for (let i = 0; i < this.length; i++) {
542
- const row = [];
543
582
 
544
- this.getRow(i, row);
583
+ const row = this.readRow(i);
545
584
 
546
585
  result.push(row);
547
586
  }
@@ -558,4 +597,20 @@ export class RowFirstTable {
558
597
 
559
598
  console.table(rows);
560
599
  }
561
- }
600
+
601
+ /**
602
+ * @deprecated
603
+ */
604
+ initialize() {
605
+ console.warn('deprecated, no longer serves any purpose. Table no longer requires initialization')
606
+ }
607
+ }
608
+
609
+ /**
610
+ * @deprecated use {@link RowFirstTable#readRow} instead
611
+ */
612
+ RowFirstTable.prototype.getRow = RowFirstTable.prototype.readRow;
613
+ /**
614
+ @deprecated use {@link RowFirstTable#writeRow} instead
615
+ */
616
+ 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,2FAqCC"}
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 };
@@ -156,7 +156,7 @@ export class TimeSeries {
156
156
  * @returns {Object}
157
157
  */
158
158
  getSampleObjectByIndex(index) {
159
- this.table.getRow(index, scratch_row);
159
+ this.table.readRow(index, scratch_row);
160
160
 
161
161
  return this.#row_to_object_allocating(scratch_row);
162
162
  }
@@ -230,7 +230,7 @@ export class TimeSeries {
230
230
  * @param {number} index
231
231
  */
232
232
  getSampleByIndex(result, index) {
233
- this.table.getRow(index, result)
233
+ this.table.readRow(index, result)
234
234
  }
235
235
 
236
236
  /**
@@ -118,7 +118,7 @@ export class FogOfWar {
118
118
 
119
119
  for (; i < numRows; i++) {
120
120
  //read row
121
- fadeMask.getRow(i, fadeRow);
121
+ fadeMask.readRow(i, fadeRow);
122
122
 
123
123
  //decode row
124
124
  const index = fadeRow[0];
@@ -109,7 +109,7 @@ export class MovingBoundingBox {
109
109
  );
110
110
 
111
111
  for (i = 0; i < length; i++) {
112
- this.positionSequence.getRow(i, tempSequenceRecord);
112
+ this.positionSequence.readRow(i, tempSequenceRecord);
113
113
 
114
114
  const x0 = tempSequenceRecord[1];
115
115
  const y0 = tempSequenceRecord[2];