@woosh/meep-engine 2.81.3 → 2.81.4
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
|
@@ -75559,6 +75559,7 @@ function planeHash(plane) {
|
|
|
75559
75559
|
* @template T
|
|
75560
75560
|
* @param {T[]} array
|
|
75561
75561
|
* @param {function(T):number} elementHashFunction
|
|
75562
|
+
* @returns {number}
|
|
75562
75563
|
*/
|
|
75563
75564
|
function computeHashArray(array, elementHashFunction) {
|
|
75564
75565
|
|
package/build/meep.module.js
CHANGED
|
@@ -75557,6 +75557,7 @@ function planeHash(plane) {
|
|
|
75557
75557
|
* @template T
|
|
75558
75558
|
* @param {T[]} array
|
|
75559
75559
|
* @param {function(T):number} elementHashFunction
|
|
75560
|
+
* @returns {number}
|
|
75560
75561
|
*/
|
|
75561
75562
|
function computeHashArray(array, elementHashFunction) {
|
|
75562
75563
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} array
|
|
4
6
|
* @param {function(T):number} elementHashFunction
|
|
7
|
+
* @returns {number}
|
|
5
8
|
*/
|
|
6
9
|
export function computeHashArray(array, elementHashFunction) {
|
|
10
|
+
assert.isArrayLike(array, 'array');
|
|
11
|
+
assert.isFunction(elementHashFunction, 'elementHashFunction');
|
|
7
12
|
|
|
8
13
|
const numArguments = array.length;
|
|
9
14
|
let hash = numArguments;
|
|
@@ -13,41 +13,43 @@ import { computeHashArray } from "../array/computeHashArray.js";
|
|
|
13
13
|
import { isArrayEqualStrict } from "../array/isArrayEqualStrict.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
16
17
|
* @readonly
|
|
17
18
|
* @enum {string}
|
|
18
19
|
*/
|
|
19
20
|
export const DataType2DataViewReaders = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
[BinaryDataType.Uint8]: "getUint8",
|
|
22
|
+
[BinaryDataType.Uint16]: "getUint16",
|
|
23
|
+
[BinaryDataType.Uint32]: "getUint32",
|
|
24
|
+
[BinaryDataType.Uint64]: "getUint64",
|
|
25
|
+
|
|
26
|
+
[BinaryDataType.Int8]: "getInt8",
|
|
27
|
+
[BinaryDataType.Int16]: "getInt16",
|
|
28
|
+
[BinaryDataType.Int32]: "getInt32",
|
|
29
|
+
[BinaryDataType.Int64]: "getInt64",
|
|
30
|
+
|
|
31
|
+
[BinaryDataType.Float32]: "getFloat32",
|
|
32
|
+
[BinaryDataType.Float64]: "getFloat64"
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
/**
|
|
36
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
35
37
|
* @readonly
|
|
36
38
|
* @enum {string}
|
|
37
39
|
*/
|
|
38
40
|
export const DataType2DataViewWriters = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
[BinaryDataType.Uint8]: "setUint8",
|
|
42
|
+
[BinaryDataType.Uint16]: "setUint16",
|
|
43
|
+
[BinaryDataType.Uint32]: "setUint32",
|
|
44
|
+
[BinaryDataType.Uint64]: "setUint64",
|
|
45
|
+
|
|
46
|
+
[BinaryDataType.Int8]: "setInt8",
|
|
47
|
+
[BinaryDataType.Int16]: "setInt16",
|
|
48
|
+
[BinaryDataType.Int32]: "setInt32",
|
|
49
|
+
[BinaryDataType.Int64]: "setInt64",
|
|
50
|
+
|
|
51
|
+
[BinaryDataType.Float32]: "setFloat32",
|
|
52
|
+
[BinaryDataType.Float64]: "setFloat64"
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
/**
|
|
@@ -67,10 +69,14 @@ function genRowReader(types, endianType = EndianType.BigEndian) {
|
|
|
67
69
|
|
|
68
70
|
const type = types[i];
|
|
69
71
|
|
|
72
|
+
const reader_name = DataType2DataViewReaders[type];
|
|
73
|
+
|
|
74
|
+
assert.isString(reader_name, 'reader_name');
|
|
75
|
+
|
|
70
76
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
71
77
|
|
|
72
78
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
73
|
-
lines.push(`result[${i}] = dataView.${
|
|
79
|
+
lines.push(`result[${i}] = dataView.${reader_name}(${offset} + byteOffset, ${littleEndianFlag});`);
|
|
74
80
|
|
|
75
81
|
offset += DataTypeByteSizes[type];
|
|
76
82
|
|
|
@@ -100,10 +106,14 @@ function genRowWriter(types, endianType = EndianType.BigEndian) {
|
|
|
100
106
|
for (let i = 0; i < numTypes; i++) {
|
|
101
107
|
const type = types[i];
|
|
102
108
|
|
|
109
|
+
const writer_name = DataType2DataViewWriters[type];
|
|
110
|
+
|
|
111
|
+
assert.isString(writer_name, 'writer_name');
|
|
112
|
+
|
|
103
113
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
104
114
|
|
|
105
115
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
106
|
-
lines.push(`dataView.${
|
|
116
|
+
lines.push(`dataView.${writer_name}(${offset} + byteOffset, record[${i}], ${littleEndianFlag});`);
|
|
107
117
|
|
|
108
118
|
offset += DataTypeByteSizes[type];
|
|
109
119
|
}
|
|
@@ -267,7 +277,7 @@ export class RowFirstTableSpec {
|
|
|
267
277
|
}
|
|
268
278
|
|
|
269
279
|
/**
|
|
270
|
-
*
|
|
280
|
+
* Produces an immutable spec, either creates a new spec or retrieves a cached version
|
|
271
281
|
* @param {BinaryDataType[]} types
|
|
272
282
|
* @param {EndianType} [endianType]
|
|
273
283
|
* @returns {RowFirstTableSpec}
|
|
@@ -276,21 +286,25 @@ export class RowFirstTableSpec {
|
|
|
276
286
|
//compute hash
|
|
277
287
|
const hash = types.join('.') + ':' + endianType;
|
|
278
288
|
|
|
279
|
-
const cachedValue =
|
|
289
|
+
const cachedValue = SPEC_CACHE.get(hash);
|
|
280
290
|
|
|
281
291
|
if (cachedValue !== null) {
|
|
282
292
|
return cachedValue;
|
|
283
293
|
}
|
|
284
294
|
|
|
285
295
|
const newValue = new RowFirstTableSpec(types);
|
|
286
|
-
|
|
296
|
+
SPEC_CACHE.put(hash, newValue);
|
|
287
297
|
|
|
288
298
|
return newValue;
|
|
289
299
|
}
|
|
290
300
|
}
|
|
291
301
|
|
|
292
302
|
|
|
293
|
-
|
|
303
|
+
/**
|
|
304
|
+
* @readonly
|
|
305
|
+
* @type {Cache<string,RowFirstTableSpec>}
|
|
306
|
+
*/
|
|
307
|
+
const SPEC_CACHE = new Cache({
|
|
294
308
|
keyHashFunction: computeStringHash
|
|
295
309
|
});
|
|
296
310
|
|