@woosh/meep-engine 2.39.31 → 2.39.34
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/core/binary/BinaryBuffer.js +825 -827
- package/core/binary/EncodingBinaryBuffer.js +38 -41
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +20 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +5 -35
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +19 -0
- package/core/collection/queue/Deque.d.ts +20 -0
- package/core/process/executor/ConcurrentExecutor.d.ts +2 -2
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +3 -3
- package/engine/ecs/speaker/VoiceSystem.js +8 -0
- package/engine/metrics/GoogleAnalyticsMetrics.js +2 -1
- package/package.json +1 -1
|
@@ -21,1076 +21,1074 @@ export const EndianType = {
|
|
|
21
21
|
const MIN_GROWTH_STEP = 1024;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
24
|
+
* 2^31-1, values above this will be cropped incorrectly when bit-shifting
|
|
25
|
+
* @type {number}
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {EndianType|boolean}
|
|
31
|
-
*/
|
|
32
|
-
this.endianness = EndianType.BigEndian;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @type {number}
|
|
37
|
-
*/
|
|
38
|
-
this.position = 0;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @type {number}
|
|
43
|
-
*/
|
|
44
|
-
this.length = 0;
|
|
27
|
+
const MAX_SAFE_UINT_VAR = 2147483647;
|
|
45
28
|
|
|
29
|
+
export class BinaryBuffer {
|
|
46
30
|
/**
|
|
47
31
|
*
|
|
48
|
-
* @
|
|
32
|
+
* @constructor
|
|
49
33
|
*/
|
|
50
|
-
|
|
34
|
+
constructor() {
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @type {EndianType|boolean}
|
|
38
|
+
*/
|
|
39
|
+
this.endianness = EndianType.BigEndian;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
this.position = 0;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @type {number}
|
|
50
|
+
*/
|
|
51
|
+
this.length = 0;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
this.capacity = 0;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @type {ArrayBuffer}
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
this.data = new ArrayBuffer(0);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @type {DataView}
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
this.dataView = new DataView(this.data);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @type {Uint8Array}
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
this.__data_uint8 = new Uint8Array(0);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @type {number}
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
this.__growFactor = 1.1;
|
|
86
|
+
}
|
|
51
87
|
|
|
52
88
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @type {ArrayBuffer}
|
|
55
|
-
* @private
|
|
89
|
+
* @param {ArrayBuffer} arrayBuffer
|
|
56
90
|
*/
|
|
57
|
-
|
|
91
|
+
fromArrayBuffer(arrayBuffer) {
|
|
92
|
+
this.data = arrayBuffer;
|
|
93
|
+
this.dataView = new DataView(arrayBuffer);
|
|
94
|
+
this.__data_uint8 = new Uint8Array(arrayBuffer);
|
|
95
|
+
|
|
96
|
+
this.capacity = arrayBuffer.byteLength;
|
|
97
|
+
//assume that all the data is useful
|
|
98
|
+
this.length = this.capacity;
|
|
99
|
+
this.position = 0;
|
|
100
|
+
}
|
|
58
101
|
|
|
59
102
|
/**
|
|
60
103
|
*
|
|
61
|
-
* @
|
|
62
|
-
* @private
|
|
104
|
+
* @returns {BinaryBuffer}
|
|
63
105
|
*/
|
|
64
|
-
|
|
106
|
+
trim() {
|
|
107
|
+
this.setCapacity(this.position);
|
|
65
108
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* @type {Uint8Array}
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
this.__data_uint8 = new Uint8Array(0);
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
72
111
|
|
|
73
112
|
/**
|
|
74
113
|
*
|
|
75
|
-
* @
|
|
76
|
-
* @private
|
|
114
|
+
* @param {number} capacity
|
|
77
115
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
116
|
+
setCapacity(capacity) {
|
|
117
|
+
const oldData = this.__data_uint8;
|
|
118
|
+
const newData = new Uint8Array(capacity);
|
|
80
119
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
BinaryBuffer.prototype.fromArrayBuffer = function (arrayBuffer) {
|
|
85
|
-
this.data = arrayBuffer;
|
|
86
|
-
this.dataView = new DataView(arrayBuffer);
|
|
87
|
-
this.__data_uint8 = new Uint8Array(arrayBuffer);
|
|
88
|
-
|
|
89
|
-
this.capacity = arrayBuffer.byteLength;
|
|
90
|
-
//assume that all the data is useful
|
|
91
|
-
this.length = this.capacity;
|
|
92
|
-
this.position = 0;
|
|
93
|
-
};
|
|
120
|
+
//copy old data
|
|
121
|
+
const copyLength = Math.min(newData.length, oldData.length);
|
|
122
|
+
newData.set(oldData.subarray(0, copyLength), 0);
|
|
94
123
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* @return {BinaryBuffer}
|
|
99
|
-
*/
|
|
100
|
-
BinaryBuffer.fromArrayBuffer = function (v) {
|
|
101
|
-
const r = new BinaryBuffer();
|
|
102
|
-
|
|
103
|
-
r.fromArrayBuffer(v);
|
|
104
|
-
|
|
105
|
-
return r;
|
|
106
|
-
};
|
|
124
|
+
this.data = newData.buffer;
|
|
125
|
+
this.__data_uint8 = newData;
|
|
126
|
+
this.dataView = new DataView(this.data);
|
|
107
127
|
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
* @returns {BinaryBuffer}
|
|
111
|
-
*/
|
|
112
|
-
BinaryBuffer.prototype.trim = function () {
|
|
113
|
-
this.setCapacity(this.position);
|
|
114
|
-
|
|
115
|
-
return this;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
-
* @param {number} capacity
|
|
121
|
-
*/
|
|
122
|
-
BinaryBuffer.prototype.setCapacity = function (capacity) {
|
|
123
|
-
const oldData = this.__data_uint8;
|
|
124
|
-
const newData = new Uint8Array(capacity);
|
|
125
|
-
|
|
126
|
-
//copy old data
|
|
127
|
-
const copyLength = Math.min(newData.length, oldData.length);
|
|
128
|
-
newData.set(oldData.subarray(0, copyLength), 0);
|
|
129
|
-
|
|
130
|
-
this.data = newData.buffer;
|
|
131
|
-
this.__data_uint8 = newData;
|
|
132
|
-
this.dataView = new DataView(this.data);
|
|
133
|
-
|
|
134
|
-
this.capacity = capacity;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
BinaryBuffer.prototype.ensureCapacity = function (minCapacity) {
|
|
138
|
-
if (this.capacity < minCapacity) {
|
|
139
|
-
const newCapacity = Math.ceil(Math.max(
|
|
140
|
-
minCapacity,
|
|
141
|
-
this.capacity * this.__growFactor,
|
|
142
|
-
this.capacity + MIN_GROWTH_STEP
|
|
143
|
-
));
|
|
144
|
-
this.setCapacity(newCapacity);
|
|
128
|
+
this.capacity = capacity;
|
|
145
129
|
}
|
|
146
|
-
};
|
|
147
130
|
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
ensureCapacity(minCapacity) {
|
|
132
|
+
if (this.capacity < minCapacity) {
|
|
133
|
+
const newCapacity = Math.ceil(Math.max(
|
|
134
|
+
minCapacity,
|
|
135
|
+
this.capacity * this.__growFactor,
|
|
136
|
+
this.capacity + MIN_GROWTH_STEP
|
|
137
|
+
));
|
|
138
|
+
this.setCapacity(newCapacity);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
150
141
|
|
|
151
|
-
|
|
142
|
+
readFloat32() {
|
|
143
|
+
const result = this.dataView.getFloat32(this.position, this.endianness);
|
|
152
144
|
|
|
153
|
-
|
|
154
|
-
};
|
|
145
|
+
this.position += 4;
|
|
155
146
|
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
158
149
|
|
|
159
|
-
|
|
150
|
+
readFloat64() {
|
|
151
|
+
const result = this.dataView.getFloat64(this.position, this.endianness);
|
|
160
152
|
|
|
161
|
-
|
|
162
|
-
};
|
|
153
|
+
this.position += 8;
|
|
163
154
|
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
166
157
|
|
|
167
|
-
|
|
158
|
+
readInt8() {
|
|
159
|
+
const result = this.dataView.getInt8(this.position);
|
|
168
160
|
|
|
169
|
-
|
|
170
|
-
};
|
|
161
|
+
this.position += 1;
|
|
171
162
|
|
|
172
|
-
|
|
173
|
-
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
174
165
|
|
|
175
|
-
|
|
166
|
+
readInt16() {
|
|
167
|
+
const result = this.dataView.getInt16(this.position, this.endianness);
|
|
176
168
|
|
|
177
|
-
|
|
178
|
-
};
|
|
169
|
+
this.position += 2;
|
|
179
170
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* @returns {number}
|
|
183
|
-
*/
|
|
184
|
-
BinaryBuffer.prototype.readInt32 = function () {
|
|
185
|
-
const result = this.dataView.getInt32(this.position, this.endianness);
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
186
173
|
|
|
187
|
-
|
|
174
|
+
/**
|
|
175
|
+
*
|
|
176
|
+
* @returns {number}
|
|
177
|
+
*/
|
|
178
|
+
readInt32() {
|
|
179
|
+
const result = this.dataView.getInt32(this.position, this.endianness);
|
|
188
180
|
|
|
189
|
-
|
|
190
|
-
};
|
|
181
|
+
this.position += 4;
|
|
191
182
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* @returns {number}
|
|
195
|
-
*/
|
|
196
|
-
BinaryBuffer.prototype.readUint8 = function () {
|
|
197
|
-
const result = this.dataView.getUint8(this.position);
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
198
185
|
|
|
199
|
-
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @returns {number}
|
|
189
|
+
*/
|
|
190
|
+
readUint8() {
|
|
191
|
+
const result = this.dataView.getUint8(this.position);
|
|
200
192
|
|
|
201
|
-
|
|
202
|
-
};
|
|
193
|
+
this.position += 1;
|
|
203
194
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
* @returns {number}
|
|
207
|
-
*/
|
|
208
|
-
BinaryBuffer.prototype.readUint16 = function () {
|
|
209
|
-
const result = this.dataView.getUint16(this.position, this.endianness);
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
210
197
|
|
|
211
|
-
|
|
198
|
+
/**
|
|
199
|
+
*
|
|
200
|
+
* @returns {number}
|
|
201
|
+
*/
|
|
202
|
+
readUint16() {
|
|
203
|
+
const result = this.dataView.getUint16(this.position, this.endianness);
|
|
212
204
|
|
|
213
|
-
|
|
214
|
-
};
|
|
205
|
+
this.position += 2;
|
|
215
206
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* @returns {number}
|
|
219
|
-
*/
|
|
220
|
-
BinaryBuffer.prototype.readUint16LE = function () {
|
|
221
|
-
const result = this.dataView.getUint16(this.position, EndianType.LittleEndian);
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
222
209
|
|
|
223
|
-
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* @returns {number}
|
|
213
|
+
*/
|
|
214
|
+
readUint16LE() {
|
|
215
|
+
const result = this.dataView.getUint16(this.position, EndianType.LittleEndian);
|
|
224
216
|
|
|
225
|
-
|
|
226
|
-
};
|
|
217
|
+
this.position += 2;
|
|
227
218
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* @returns {number}
|
|
231
|
-
*/
|
|
232
|
-
BinaryBuffer.prototype.readUint16BE = function () {
|
|
233
|
-
const result = this.dataView.getUint16(this.position, EndianType.BigEndian);
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
234
221
|
|
|
235
|
-
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
* @returns {number}
|
|
225
|
+
*/
|
|
226
|
+
readUint16BE() {
|
|
227
|
+
const result = this.dataView.getUint16(this.position, EndianType.BigEndian);
|
|
236
228
|
|
|
237
|
-
|
|
238
|
-
};
|
|
229
|
+
this.position += 2;
|
|
239
230
|
|
|
240
|
-
|
|
241
|
-
*
|
|
242
|
-
* @returns {number}
|
|
243
|
-
*/
|
|
244
|
-
BinaryBuffer.prototype.readUint24 = function () {
|
|
245
|
-
if (this.endianness === EndianType.BigEndian) {
|
|
246
|
-
return this.readUint24BE();
|
|
247
|
-
} else {
|
|
248
|
-
return this.readUint24LE();
|
|
231
|
+
return result;
|
|
249
232
|
}
|
|
250
|
-
};
|
|
251
233
|
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
234
|
+
/**
|
|
235
|
+
*
|
|
236
|
+
* @returns {number}
|
|
237
|
+
*/
|
|
238
|
+
readUint24() {
|
|
239
|
+
if (this.endianness === EndianType.BigEndian) {
|
|
240
|
+
return this.readUint24BE();
|
|
241
|
+
} else {
|
|
242
|
+
return this.readUint24LE();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
260
245
|
|
|
261
|
-
|
|
246
|
+
/**
|
|
247
|
+
*
|
|
248
|
+
* @returns {number}
|
|
249
|
+
*/
|
|
250
|
+
readUint24LE() {
|
|
251
|
+
const b0 = this.dataView.getUint8(this.position);
|
|
252
|
+
const b1 = this.dataView.getUint8(this.position + 1);
|
|
253
|
+
const b2 = this.dataView.getUint8(this.position + 2);
|
|
262
254
|
|
|
263
|
-
|
|
264
|
-
};
|
|
255
|
+
this.position += 3;
|
|
265
256
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
* @returns {number}
|
|
269
|
-
*/
|
|
270
|
-
BinaryBuffer.prototype.readUint24BE = function () {
|
|
271
|
-
const b0 = this.dataView.getUint8(this.position);
|
|
272
|
-
const b1 = this.dataView.getUint8(this.position + 1);
|
|
273
|
-
const b2 = this.dataView.getUint8(this.position + 2);
|
|
257
|
+
return b0 | (b1 << 8) | (b2 << 16);
|
|
258
|
+
}
|
|
274
259
|
|
|
275
|
-
|
|
260
|
+
/**
|
|
261
|
+
*
|
|
262
|
+
* @returns {number}
|
|
263
|
+
*/
|
|
264
|
+
readUint24BE() {
|
|
265
|
+
const b0 = this.dataView.getUint8(this.position);
|
|
266
|
+
const b1 = this.dataView.getUint8(this.position + 1);
|
|
267
|
+
const b2 = this.dataView.getUint8(this.position + 2);
|
|
276
268
|
|
|
277
|
-
|
|
278
|
-
};
|
|
269
|
+
this.position += 3;
|
|
279
270
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
* @returns {number}
|
|
283
|
-
*/
|
|
284
|
-
BinaryBuffer.prototype.readUint32 = function () {
|
|
285
|
-
const result = this.dataView.getUint32(this.position, this.endianness);
|
|
271
|
+
return b2 | (b1 << 8) | (b0 << 16);
|
|
272
|
+
}
|
|
286
273
|
|
|
287
|
-
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @returns {number}
|
|
277
|
+
*/
|
|
278
|
+
readUint32() {
|
|
279
|
+
const result = this.dataView.getUint32(this.position, this.endianness);
|
|
288
280
|
|
|
289
|
-
|
|
290
|
-
};
|
|
281
|
+
this.position += 4;
|
|
291
282
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* @returns {number}
|
|
295
|
-
*/
|
|
296
|
-
BinaryBuffer.prototype.readUint32LE = function () {
|
|
297
|
-
const result = this.dataView.getUint32(this.position, EndianType.LittleEndian);
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
298
285
|
|
|
299
|
-
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @returns {number}
|
|
289
|
+
*/
|
|
290
|
+
readUint32LE() {
|
|
291
|
+
const result = this.dataView.getUint32(this.position, EndianType.LittleEndian);
|
|
300
292
|
|
|
301
|
-
|
|
302
|
-
};
|
|
293
|
+
this.position += 4;
|
|
303
294
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
* @returns {number}
|
|
307
|
-
*/
|
|
308
|
-
BinaryBuffer.prototype.readUint32BE = function () {
|
|
309
|
-
const result = this.dataView.getUint32(this.position, EndianType.BigEndian);
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
310
297
|
|
|
311
|
-
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @returns {number}
|
|
301
|
+
*/
|
|
302
|
+
readUint32BE() {
|
|
303
|
+
const result = this.dataView.getUint32(this.position, EndianType.BigEndian);
|
|
312
304
|
|
|
313
|
-
|
|
314
|
-
};
|
|
305
|
+
this.position += 4;
|
|
315
306
|
|
|
316
|
-
|
|
317
|
-
*
|
|
318
|
-
* @param {number} destination_offset starting index in the destination array
|
|
319
|
-
* @param {number} length number of elements to read
|
|
320
|
-
* @param {Uint8Array} destination
|
|
321
|
-
*/
|
|
322
|
-
BinaryBuffer.prototype.readUint8Array = function (destination, destination_offset, length) {
|
|
323
|
-
for (let i = 0; i < length; i++) {
|
|
324
|
-
destination[i + destination_offset] = this.readUint8();
|
|
307
|
+
return result;
|
|
325
308
|
}
|
|
326
|
-
};
|
|
327
309
|
|
|
328
|
-
/**
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
310
|
+
/**
|
|
311
|
+
*
|
|
312
|
+
* @param {number} destination_offset starting index in the destination array
|
|
313
|
+
* @param {number} length number of elements to read
|
|
314
|
+
* @param {Uint8Array} destination
|
|
315
|
+
*/
|
|
316
|
+
readUint8Array(destination, destination_offset, length) {
|
|
317
|
+
for (let i = 0; i < length; i++) {
|
|
318
|
+
destination[i + destination_offset] = this.readUint8();
|
|
319
|
+
}
|
|
337
320
|
}
|
|
338
|
-
};
|
|
339
321
|
|
|
340
|
-
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
322
|
+
/**
|
|
323
|
+
*
|
|
324
|
+
* @param {number} destination_offset starting index in the destination array
|
|
325
|
+
* @param {number} length number of elements to read
|
|
326
|
+
* @param {Uint16Array} destination
|
|
327
|
+
*/
|
|
328
|
+
readUint16Array(destination, destination_offset, length) {
|
|
329
|
+
for (let i = 0; i < length; i++) {
|
|
330
|
+
destination[i + destination_offset] = this.readUint16();
|
|
331
|
+
}
|
|
349
332
|
}
|
|
350
|
-
};
|
|
351
333
|
|
|
352
|
-
/**
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
334
|
+
/**
|
|
335
|
+
*
|
|
336
|
+
* @param {number} destination_offset starting index in the destination array
|
|
337
|
+
* @param {number} length number of elements to read
|
|
338
|
+
* @param {Uint32Array} destination
|
|
339
|
+
*/
|
|
340
|
+
readUint32Array(destination, destination_offset, length) {
|
|
341
|
+
for (let i = 0; i < length; i++) {
|
|
342
|
+
destination[i + destination_offset] = this.readUint32();
|
|
343
|
+
}
|
|
361
344
|
}
|
|
362
|
-
};
|
|
363
345
|
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
346
|
+
/**
|
|
347
|
+
*
|
|
348
|
+
* @param {number} destination_offset starting index in the destination array
|
|
349
|
+
* @param {number} length number of elements to read
|
|
350
|
+
* @param {Int8Array} destination
|
|
351
|
+
*/
|
|
352
|
+
readInt8Array(destination, destination_offset, length) {
|
|
353
|
+
for (let i = 0; i < length; i++) {
|
|
354
|
+
destination[i + destination_offset] = this.readInt8();
|
|
355
|
+
}
|
|
373
356
|
}
|
|
374
|
-
};
|
|
375
357
|
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
358
|
+
/**
|
|
359
|
+
*
|
|
360
|
+
* @param {number} destination_offset starting index in the destination array
|
|
361
|
+
* @param {number} length number of elements to read
|
|
362
|
+
* @param {Int16Array} destination
|
|
363
|
+
*/
|
|
364
|
+
readInt16Array(destination, destination_offset, length) {
|
|
365
|
+
for (let i = 0; i < length; i++) {
|
|
366
|
+
destination[i + destination_offset] = this.readInt16();
|
|
367
|
+
}
|
|
385
368
|
}
|
|
386
|
-
};
|
|
387
369
|
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* @param {number} destination_offset starting index in the destination array
|
|
373
|
+
* @param {number} length number of elements to read
|
|
374
|
+
* @param {Int32Array} destination
|
|
375
|
+
*/
|
|
376
|
+
readInt32Array(destination, destination_offset, length) {
|
|
377
|
+
for (let i = 0; i < length; i++) {
|
|
378
|
+
destination[i + destination_offset] = this.readInt32();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
388
381
|
|
|
389
|
-
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
382
|
+
/**
|
|
383
|
+
*
|
|
384
|
+
* @param {number} destination_offset starting index in the destination array
|
|
385
|
+
* @param {number} length number of elements to read
|
|
386
|
+
* @param {Float32Array|number[]} destination
|
|
387
|
+
*/
|
|
388
|
+
readFloat32Array(destination, destination_offset, length) {
|
|
389
|
+
for (let i = 0; i < length; i++) {
|
|
390
|
+
destination[i + destination_offset] = this.readFloat32();
|
|
391
|
+
}
|
|
398
392
|
}
|
|
399
|
-
};
|
|
400
393
|
|
|
401
|
-
/**
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
394
|
+
/**
|
|
395
|
+
*
|
|
396
|
+
* @param {number} destination_offset starting index in the destination array
|
|
397
|
+
* @param {number} length number of elements to read
|
|
398
|
+
* @param {Float64Array} destination
|
|
399
|
+
*/
|
|
400
|
+
readFloat64Array(destination, destination_offset, length) {
|
|
401
|
+
for (let i = 0; i < length; i++) {
|
|
402
|
+
destination[i + destination_offset] = this.readFloat64();
|
|
403
|
+
}
|
|
410
404
|
}
|
|
411
|
-
};
|
|
412
405
|
|
|
413
|
-
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @param {number} source_offset starting index in the source array
|
|
409
|
+
* @param {number} length number of elements to read
|
|
410
|
+
* @param {Float32Array|number[]} source
|
|
411
|
+
*/
|
|
412
|
+
writeFloat32Array(source, source_offset, length) {
|
|
413
|
+
for (let i = 0; i < length; i++) {
|
|
414
|
+
this.writeFloat32(source[i + source_offset]);
|
|
415
|
+
}
|
|
422
416
|
}
|
|
423
|
-
};
|
|
424
417
|
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
418
|
+
/**
|
|
419
|
+
*
|
|
420
|
+
* @param {number} value
|
|
421
|
+
*/
|
|
422
|
+
writeFloat32(value) {
|
|
423
|
+
const end = this.position + 4;
|
|
424
|
+
this.ensureCapacity(end);
|
|
432
425
|
|
|
433
|
-
|
|
426
|
+
this.dataView.setFloat32(this.position, value, this.endianness);
|
|
434
427
|
|
|
435
|
-
|
|
436
|
-
}
|
|
428
|
+
this.position = end;
|
|
429
|
+
}
|
|
437
430
|
|
|
438
|
-
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
431
|
+
/**
|
|
432
|
+
*
|
|
433
|
+
* @param {number} value
|
|
434
|
+
*/
|
|
435
|
+
writeFloat64(value) {
|
|
436
|
+
const end = this.position + 8;
|
|
437
|
+
this.ensureCapacity(end);
|
|
445
438
|
|
|
446
|
-
|
|
439
|
+
this.dataView.setFloat64(this.position, value, this.endianness);
|
|
447
440
|
|
|
448
|
-
|
|
449
|
-
}
|
|
441
|
+
this.position = end;
|
|
442
|
+
}
|
|
450
443
|
|
|
451
|
-
/**
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
444
|
+
/**
|
|
445
|
+
*
|
|
446
|
+
* @param {number} value
|
|
447
|
+
*/
|
|
448
|
+
writeInt8(value) {
|
|
449
|
+
const end = this.position + 1;
|
|
450
|
+
this.ensureCapacity(end);
|
|
458
451
|
|
|
459
|
-
|
|
452
|
+
this.dataView.setInt8(this.position, value);
|
|
460
453
|
|
|
461
|
-
|
|
462
|
-
}
|
|
454
|
+
this.position = end;
|
|
455
|
+
}
|
|
463
456
|
|
|
464
|
-
/**
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
457
|
+
/**
|
|
458
|
+
*
|
|
459
|
+
* @param {number} value
|
|
460
|
+
*/
|
|
461
|
+
writeInt16(value) {
|
|
462
|
+
const end = this.position + 2;
|
|
463
|
+
this.ensureCapacity(end);
|
|
471
464
|
|
|
472
|
-
|
|
465
|
+
this.dataView.setInt16(this.position, value, this.endianness);
|
|
473
466
|
|
|
474
|
-
|
|
475
|
-
}
|
|
467
|
+
this.position = end;
|
|
468
|
+
}
|
|
476
469
|
|
|
477
|
-
/**
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
470
|
+
/**
|
|
471
|
+
*
|
|
472
|
+
* @param {number} value
|
|
473
|
+
*/
|
|
474
|
+
writeInt32(value) {
|
|
475
|
+
const end = this.position + 4;
|
|
476
|
+
this.ensureCapacity(end);
|
|
484
477
|
|
|
485
|
-
|
|
478
|
+
this.dataView.setInt32(this.position, value, this.endianness);
|
|
486
479
|
|
|
487
|
-
|
|
488
|
-
}
|
|
480
|
+
this.position = end;
|
|
481
|
+
}
|
|
489
482
|
|
|
490
|
-
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
483
|
+
/**
|
|
484
|
+
*
|
|
485
|
+
* @param {number} value
|
|
486
|
+
*/
|
|
487
|
+
writeUint8(value) {
|
|
488
|
+
const end = this.position + 1;
|
|
489
|
+
this.ensureCapacity(end);
|
|
497
490
|
|
|
498
|
-
|
|
491
|
+
this.dataView.setUint8(this.position, value);
|
|
499
492
|
|
|
500
|
-
|
|
501
|
-
}
|
|
493
|
+
this.position = end;
|
|
494
|
+
}
|
|
502
495
|
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
496
|
+
/**
|
|
497
|
+
*
|
|
498
|
+
* @param {Uint8Array|number[]} source
|
|
499
|
+
* @param {number} source_offset
|
|
500
|
+
* @param {number} length
|
|
501
|
+
*/
|
|
502
|
+
writeUint8Array(source, source_offset, length) {
|
|
503
|
+
for (let i = 0; i < length; i++) {
|
|
504
|
+
this.writeUint8(source[source_offset + i]);
|
|
505
|
+
}
|
|
512
506
|
}
|
|
513
|
-
}
|
|
514
507
|
|
|
515
|
-
/**
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param {number} value
|
|
511
|
+
*/
|
|
512
|
+
writeUint16(value) {
|
|
513
|
+
const end = this.position + 2;
|
|
514
|
+
this.ensureCapacity(end);
|
|
522
515
|
|
|
523
|
-
|
|
516
|
+
this.dataView.setUint16(this.position, value, this.endianness);
|
|
524
517
|
|
|
525
|
-
|
|
526
|
-
}
|
|
518
|
+
this.position = end;
|
|
519
|
+
}
|
|
527
520
|
|
|
528
|
-
/**
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
521
|
+
/**
|
|
522
|
+
*
|
|
523
|
+
* @param {number} value
|
|
524
|
+
*/
|
|
525
|
+
writeUint16BE(value) {
|
|
526
|
+
const end = this.position + 2;
|
|
527
|
+
this.ensureCapacity(end);
|
|
535
528
|
|
|
536
|
-
|
|
529
|
+
this.dataView.setUint16(this.position, value, EndianType.BigEndian);
|
|
537
530
|
|
|
538
|
-
|
|
539
|
-
}
|
|
531
|
+
this.position = end;
|
|
532
|
+
}
|
|
540
533
|
|
|
541
|
-
/**
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
534
|
+
/**
|
|
535
|
+
*
|
|
536
|
+
* @param {number} value
|
|
537
|
+
*/
|
|
538
|
+
writeUint16LE(value) {
|
|
539
|
+
const end = this.position + 2;
|
|
540
|
+
this.ensureCapacity(end);
|
|
548
541
|
|
|
549
|
-
|
|
542
|
+
this.dataView.setUint16(this.position, value, EndianType.LittleEndian);
|
|
550
543
|
|
|
551
|
-
|
|
552
|
-
}
|
|
544
|
+
this.position = end;
|
|
545
|
+
}
|
|
553
546
|
|
|
554
|
-
/**
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
547
|
+
/**
|
|
548
|
+
*
|
|
549
|
+
* @param {Uint16Array|number[]} source
|
|
550
|
+
* @param {number} source_offset
|
|
551
|
+
* @param {number} length
|
|
552
|
+
*/
|
|
553
|
+
writeUint16Array(source, source_offset, length) {
|
|
554
|
+
for (let i = 0; i < length; i++) {
|
|
555
|
+
this.writeUint16(source[source_offset + i]);
|
|
556
|
+
}
|
|
563
557
|
}
|
|
564
|
-
}
|
|
565
558
|
|
|
566
|
-
/**
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
559
|
+
/**
|
|
560
|
+
*
|
|
561
|
+
* @param {number} value
|
|
562
|
+
*/
|
|
563
|
+
writeUint24(value) {
|
|
564
|
+
if (this.endianness === EndianType.BigEndian) {
|
|
565
|
+
this.writeUint24BE(value);
|
|
566
|
+
} else {
|
|
567
|
+
this.writeUint24LE(value);
|
|
568
|
+
}
|
|
575
569
|
}
|
|
576
|
-
};
|
|
577
570
|
|
|
578
|
-
/**
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
571
|
+
/**
|
|
572
|
+
*
|
|
573
|
+
* @param {number} value
|
|
574
|
+
*/
|
|
575
|
+
writeUint24BE(value) {
|
|
576
|
+
const end = this.position + 3;
|
|
584
577
|
|
|
585
|
-
|
|
578
|
+
this.ensureCapacity(end);
|
|
586
579
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
580
|
+
const b0 = value & 0xFF;
|
|
581
|
+
const b1 = (value >> 8) & 0xFF;
|
|
582
|
+
const b2 = (value >> 16) & 0xFF;
|
|
590
583
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
584
|
+
this.dataView.setUint8(this.position, b2);
|
|
585
|
+
this.dataView.setUint8(this.position + 1, b1);
|
|
586
|
+
this.dataView.setUint8(this.position + 2, b0);
|
|
594
587
|
|
|
595
|
-
|
|
596
|
-
}
|
|
588
|
+
this.position = end;
|
|
589
|
+
}
|
|
597
590
|
|
|
598
|
-
/**
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
591
|
+
/**
|
|
592
|
+
*
|
|
593
|
+
* @param {number} value
|
|
594
|
+
*/
|
|
595
|
+
writeUint24LE(value) {
|
|
596
|
+
const end = this.position + 3;
|
|
604
597
|
|
|
605
|
-
|
|
598
|
+
this.ensureCapacity(end);
|
|
606
599
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
600
|
+
const b0 = value & 0xFF;
|
|
601
|
+
const b1 = (value >> 8) & 0xFF;
|
|
602
|
+
const b2 = (value >> 16) & 0xFF;
|
|
610
603
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
604
|
+
this.dataView.setUint8(this.position, b0);
|
|
605
|
+
this.dataView.setUint8(this.position + 1, b1);
|
|
606
|
+
this.dataView.setUint8(this.position + 2, b2);
|
|
614
607
|
|
|
615
|
-
|
|
616
|
-
}
|
|
608
|
+
this.position = end;
|
|
609
|
+
}
|
|
617
610
|
|
|
618
|
-
/**
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
611
|
+
/**
|
|
612
|
+
* Write Uint of variable length
|
|
613
|
+
* NOTE: uses 7-bit encoding with 1 bit used for carry-over flag
|
|
614
|
+
* @param {number} value
|
|
615
|
+
*/
|
|
616
|
+
writeUintVar(value) {
|
|
617
|
+
assert.isNonNegativeInteger(value, 'value');
|
|
618
|
+
assert.ok(value <= MAX_SAFE_UINT_VAR, `value=[${value}] exceeds maximum safe limit[=${MAX_SAFE_UINT_VAR}]`);
|
|
623
619
|
|
|
624
|
-
|
|
625
|
-
* Write Uint of variable length
|
|
626
|
-
* NOTE: uses 7-bit encoding with 1 bit used for carry-over flag
|
|
627
|
-
* @param {number} value
|
|
628
|
-
*/
|
|
629
|
-
BinaryBuffer.prototype.writeUintVar = function (value) {
|
|
630
|
-
assert.isNonNegativeInteger(value, 'value');
|
|
631
|
-
assert.ok(value <= MAX_SAFE_UINT_VAR, `value=[${value}] exceeds maximum safe limit[=${MAX_SAFE_UINT_VAR}]`);
|
|
620
|
+
let first = true;
|
|
632
621
|
|
|
633
|
-
|
|
622
|
+
while (first || value !== 0) {
|
|
623
|
+
first = false;
|
|
634
624
|
|
|
635
|
-
|
|
636
|
-
first = false;
|
|
625
|
+
let lower7bits = (value & 0x7f);
|
|
637
626
|
|
|
638
|
-
|
|
627
|
+
value >>= 7;
|
|
639
628
|
|
|
640
|
-
|
|
629
|
+
if (value > 0) {
|
|
630
|
+
//write carry-over flag
|
|
631
|
+
lower7bits |= 128;
|
|
632
|
+
}
|
|
641
633
|
|
|
642
|
-
|
|
643
|
-
//write carry-over flag
|
|
644
|
-
lower7bits |= 128;
|
|
634
|
+
this.writeUint8(lower7bits);
|
|
645
635
|
}
|
|
646
|
-
|
|
647
|
-
this.writeUint8(lower7bits);
|
|
648
636
|
}
|
|
649
|
-
};
|
|
650
637
|
|
|
651
|
-
/**
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
638
|
+
/**
|
|
639
|
+
* Read Uint of variable length, a compliment to {@link #writeUintVar}
|
|
640
|
+
* @returns {number}
|
|
641
|
+
*/
|
|
642
|
+
readUintVar() {
|
|
643
|
+
let more = true;
|
|
644
|
+
let value = 0;
|
|
645
|
+
let shift = 0;
|
|
659
646
|
|
|
660
|
-
|
|
661
|
-
|
|
647
|
+
while (more) {
|
|
648
|
+
let lower7bits = this.readUint8();
|
|
662
649
|
|
|
663
|
-
|
|
664
|
-
|
|
650
|
+
//read carry-over flag
|
|
651
|
+
more = (lower7bits & 128) !== 0;
|
|
665
652
|
|
|
666
|
-
|
|
667
|
-
|
|
653
|
+
//read value part of the byte
|
|
654
|
+
value |= (lower7bits & 0x7f) << shift;
|
|
668
655
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
656
|
+
//increment shift
|
|
657
|
+
shift += 7;
|
|
658
|
+
}
|
|
672
659
|
|
|
673
|
-
|
|
674
|
-
}
|
|
660
|
+
return value;
|
|
661
|
+
}
|
|
675
662
|
|
|
663
|
+
/**
|
|
664
|
+
*
|
|
665
|
+
* @param {number} value
|
|
666
|
+
*/
|
|
667
|
+
writeUint32(value) {
|
|
668
|
+
const end = this.position + 4;
|
|
669
|
+
this.ensureCapacity(end);
|
|
676
670
|
|
|
677
|
-
|
|
678
|
-
*
|
|
679
|
-
* @param {number} value
|
|
680
|
-
*/
|
|
681
|
-
BinaryBuffer.prototype.writeUint32 = function (value) {
|
|
682
|
-
const end = this.position + 4;
|
|
683
|
-
this.ensureCapacity(end);
|
|
671
|
+
this.dataView.setUint32(this.position, value, this.endianness);
|
|
684
672
|
|
|
685
|
-
|
|
673
|
+
this.position = end;
|
|
674
|
+
}
|
|
686
675
|
|
|
687
|
-
|
|
688
|
-
|
|
676
|
+
/**
|
|
677
|
+
*
|
|
678
|
+
* @param {number} value
|
|
679
|
+
*/
|
|
680
|
+
writeUint32BE(value) {
|
|
681
|
+
const end = this.position + 4;
|
|
682
|
+
this.ensureCapacity(end);
|
|
689
683
|
|
|
690
|
-
|
|
691
|
-
*
|
|
692
|
-
* @param {number} value
|
|
693
|
-
*/
|
|
694
|
-
BinaryBuffer.prototype.writeUint32BE = function (value) {
|
|
695
|
-
const end = this.position + 4;
|
|
696
|
-
this.ensureCapacity(end);
|
|
684
|
+
this.dataView.setUint32(this.position, value, EndianType.BigEndian);
|
|
697
685
|
|
|
698
|
-
|
|
686
|
+
this.position = end;
|
|
687
|
+
}
|
|
699
688
|
|
|
700
|
-
|
|
701
|
-
|
|
689
|
+
/**
|
|
690
|
+
*
|
|
691
|
+
* @param {number} value
|
|
692
|
+
*/
|
|
693
|
+
writeUint32LE(value) {
|
|
694
|
+
const end = this.position + 4;
|
|
695
|
+
this.ensureCapacity(end);
|
|
702
696
|
|
|
703
|
-
|
|
704
|
-
*
|
|
705
|
-
* @param {number} value
|
|
706
|
-
*/
|
|
707
|
-
BinaryBuffer.prototype.writeUint32LE = function (value) {
|
|
708
|
-
const end = this.position + 4;
|
|
709
|
-
this.ensureCapacity(end);
|
|
697
|
+
this.dataView.setUint32(this.position, value, EndianType.LittleEndian);
|
|
710
698
|
|
|
711
|
-
|
|
699
|
+
this.position = end;
|
|
700
|
+
}
|
|
712
701
|
|
|
713
|
-
|
|
714
|
-
|
|
702
|
+
/**
|
|
703
|
+
*
|
|
704
|
+
* @param {Uint8Array|Uint8ClampedArray} array
|
|
705
|
+
* @param {number} source_offset
|
|
706
|
+
* @param {number} length
|
|
707
|
+
*/
|
|
708
|
+
writeBytes(array, source_offset, length) {
|
|
709
|
+
const source_end = source_offset + length;
|
|
710
|
+
assert.greaterThanOrEqual(array.length, source_end, 'source array underflow');
|
|
715
711
|
|
|
716
|
-
|
|
717
|
-
*
|
|
718
|
-
* @param {Uint8Array|Uint8ClampedArray} array
|
|
719
|
-
* @param {number} source_offset
|
|
720
|
-
* @param {number} length
|
|
721
|
-
*/
|
|
722
|
-
BinaryBuffer.prototype.writeBytes = function (array, source_offset, length) {
|
|
723
|
-
const source_end = source_offset + length;
|
|
724
|
-
assert.greaterThanOrEqual(array.length, source_end, 'source array underflow');
|
|
712
|
+
const targetAddress = this.position;
|
|
725
713
|
|
|
726
|
-
|
|
714
|
+
const end = targetAddress + length;
|
|
727
715
|
|
|
728
|
-
|
|
716
|
+
this.ensureCapacity(end);
|
|
729
717
|
|
|
730
|
-
|
|
718
|
+
if (source_offset === 0 && array.length === length) {
|
|
719
|
+
// copying entire source array
|
|
731
720
|
|
|
732
|
-
|
|
733
|
-
// copying entire source array
|
|
721
|
+
this.__data_uint8.set(array, targetAddress);
|
|
734
722
|
|
|
735
|
-
|
|
723
|
+
} else if (typeof array.subarray === "function") {
|
|
724
|
+
// typed array, use "subarray" method
|
|
736
725
|
|
|
737
|
-
|
|
738
|
-
// typed array, use "subarray" method
|
|
726
|
+
this.__data_uint8.set(array.subarray(source_offset, source_end), targetAddress);
|
|
739
727
|
|
|
740
|
-
|
|
728
|
+
} else {
|
|
729
|
+
// not a typed array, copy byte by byte manually
|
|
741
730
|
|
|
742
|
-
|
|
743
|
-
|
|
731
|
+
for (let i = 0; i < length; i++) {
|
|
732
|
+
this.__data_uint8[targetAddress + i] = array[source_offset + i];
|
|
733
|
+
}
|
|
744
734
|
|
|
745
|
-
for (let i = 0; i < length; i++) {
|
|
746
|
-
this.__data_uint8[targetAddress + i] = array[source_offset + i];
|
|
747
735
|
}
|
|
748
736
|
|
|
737
|
+
this.position = end;
|
|
749
738
|
}
|
|
750
739
|
|
|
751
|
-
|
|
752
|
-
|
|
740
|
+
/**
|
|
741
|
+
*
|
|
742
|
+
* @param {Uint8Array} destination
|
|
743
|
+
* @param {number} destination_offset
|
|
744
|
+
* @param {number} length
|
|
745
|
+
*/
|
|
746
|
+
readBytes(destination, destination_offset, length) {
|
|
747
|
+
const source_position = this.position;
|
|
753
748
|
|
|
754
|
-
|
|
755
|
-
*
|
|
756
|
-
* @param {Uint8Array} destination
|
|
757
|
-
* @param {number} destination_offset
|
|
758
|
-
* @param {number} length
|
|
759
|
-
*/
|
|
760
|
-
BinaryBuffer.prototype.readBytes = function (destination, destination_offset, length) {
|
|
761
|
-
const source_position = this.position;
|
|
749
|
+
const end = source_position + length;
|
|
762
750
|
|
|
763
|
-
|
|
751
|
+
const uint8 = this.__data_uint8;
|
|
764
752
|
|
|
765
|
-
|
|
753
|
+
if (length < 128) {
|
|
754
|
+
// small copy
|
|
755
|
+
array_copy(uint8, source_position, destination, destination_offset, length);
|
|
756
|
+
} else {
|
|
757
|
+
destination.set(uint8.subarray(source_position, end), destination_offset);
|
|
758
|
+
}
|
|
766
759
|
|
|
767
|
-
|
|
768
|
-
// small copy
|
|
769
|
-
array_copy(uint8, source_position, destination, destination_offset, length);
|
|
770
|
-
} else {
|
|
771
|
-
destination.set(uint8.subarray(source_position, end), destination_offset);
|
|
760
|
+
this.position = end;
|
|
772
761
|
}
|
|
773
762
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
this.writeUint32(4294967294);
|
|
792
|
-
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
763
|
+
/**
|
|
764
|
+
* Adapted from https://github.com/samthor/fast-text-encoding/blob/master/text.js
|
|
765
|
+
* @licence Original license is Apache 2.0
|
|
766
|
+
* @param {String} string
|
|
767
|
+
*/
|
|
768
|
+
writeUTF8String(string) {
|
|
769
|
+
if (string === null) {
|
|
770
|
+
//mark NULL
|
|
771
|
+
this.writeUint32(4294967295);
|
|
772
|
+
//bail, no string data to write
|
|
773
|
+
return;
|
|
774
|
+
} else if (string === undefined) {
|
|
775
|
+
//mark undefined
|
|
776
|
+
this.writeUint32(4294967294);
|
|
777
|
+
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
795
780
|
|
|
796
781
|
|
|
797
|
-
|
|
798
|
-
|
|
782
|
+
let pos = 0;
|
|
783
|
+
const len = string.length;
|
|
799
784
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
785
|
+
if (len >= 4294967294) {
|
|
786
|
+
throw new Error('String is too long');
|
|
787
|
+
}
|
|
803
788
|
|
|
804
|
-
|
|
805
|
-
|
|
789
|
+
//mark non-NULL
|
|
790
|
+
this.writeUint32(len);
|
|
806
791
|
|
|
807
|
-
|
|
792
|
+
const startPosition = this.position;
|
|
808
793
|
|
|
809
|
-
|
|
794
|
+
let at = startPosition; // output position
|
|
810
795
|
|
|
811
|
-
|
|
796
|
+
let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
|
|
812
797
|
|
|
813
|
-
|
|
798
|
+
this.ensureCapacity(tlen + at);
|
|
814
799
|
|
|
815
|
-
|
|
800
|
+
let target = this.__data_uint8; // ... but at 8 byte offset
|
|
816
801
|
|
|
817
802
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
if (value >= 0xd800 && value <= 0xdbff) {
|
|
821
|
-
// high surrogate
|
|
822
|
-
if (pos < len) {
|
|
823
|
-
const extra = string.charCodeAt(pos);
|
|
824
|
-
if ((extra & 0xfc00) === 0xdc00) {
|
|
825
|
-
++pos;
|
|
826
|
-
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
803
|
+
while (pos < len) {
|
|
804
|
+
let value = string.charCodeAt(pos++);
|
|
829
805
|
if (value >= 0xd800 && value <= 0xdbff) {
|
|
830
|
-
|
|
806
|
+
// high surrogate
|
|
807
|
+
if (pos < len) {
|
|
808
|
+
const extra = string.charCodeAt(pos);
|
|
809
|
+
if ((extra & 0xfc00) === 0xdc00) {
|
|
810
|
+
++pos;
|
|
811
|
+
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
if (value >= 0xd800 && value <= 0xdbff) {
|
|
815
|
+
continue; // drop lone surrogate
|
|
816
|
+
}
|
|
831
817
|
}
|
|
832
|
-
}
|
|
833
818
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
819
|
+
// expand the buffer if we couldn't write 4 bytes
|
|
820
|
+
if (at + 4 > this.capacity) {
|
|
821
|
+
tlen += 8; // minimum extra
|
|
822
|
+
tlen *= (1.0 + (pos / len) * 2); // take 2x the remaining
|
|
823
|
+
tlen = (tlen >> 3) << 3; // 8 byte offset
|
|
839
824
|
|
|
840
|
-
|
|
825
|
+
this.ensureCapacity(tlen + startPosition);
|
|
841
826
|
|
|
842
|
-
|
|
843
|
-
|
|
827
|
+
target = this.__data_uint8;
|
|
828
|
+
}
|
|
844
829
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
830
|
+
if ((value & 0xffffff80) === 0) { // 1-byte
|
|
831
|
+
target[at++] = value; // ASCII
|
|
832
|
+
continue;
|
|
833
|
+
} else if ((value & 0xfffff800) === 0) { // 2-byte
|
|
834
|
+
target[at++] = ((value >> 6) & 0x1f) | 0xc0;
|
|
835
|
+
} else if ((value & 0xffff0000) === 0) { // 3-byte
|
|
836
|
+
target[at++] = ((value >> 12) & 0x0f) | 0xe0;
|
|
837
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
838
|
+
} else if ((value & 0xffe00000) === 0) { // 4-byte
|
|
839
|
+
target[at++] = ((value >> 18) & 0x07) | 0xf0;
|
|
840
|
+
target[at++] = ((value >> 12) & 0x3f) | 0x80;
|
|
841
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
842
|
+
} else {
|
|
843
|
+
// FIXME: do we care
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
860
848
|
}
|
|
861
849
|
|
|
862
|
-
|
|
850
|
+
this.position = at;
|
|
863
851
|
}
|
|
864
852
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
//undefined string
|
|
882
|
-
return undefined;
|
|
883
|
-
}
|
|
853
|
+
/**
|
|
854
|
+
* Adapted from https://github.com/samthor/fast-text-encoding/blob/master/text.js
|
|
855
|
+
* @licence Original license is Apache 2.0
|
|
856
|
+
* @returns {String}
|
|
857
|
+
*/
|
|
858
|
+
readUTF8String() {
|
|
859
|
+
//check for null
|
|
860
|
+
const stringLength = this.readUint32();
|
|
861
|
+
|
|
862
|
+
if (stringLength === 4294967295) {
|
|
863
|
+
//null string
|
|
864
|
+
return null;
|
|
865
|
+
} else if (stringLength === 4294967294) {
|
|
866
|
+
//undefined string
|
|
867
|
+
return undefined;
|
|
868
|
+
}
|
|
884
869
|
|
|
885
|
-
|
|
870
|
+
const bytes = this.__data_uint8;
|
|
886
871
|
|
|
887
872
|
|
|
888
|
-
|
|
873
|
+
let result = "";
|
|
889
874
|
|
|
890
|
-
|
|
875
|
+
let i = this.position;
|
|
891
876
|
|
|
892
|
-
|
|
877
|
+
let charCount = 0;
|
|
893
878
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
879
|
+
while (i < this.capacity && charCount < stringLength) {
|
|
880
|
+
const byte1 = bytes[i++];
|
|
881
|
+
let codePoint;
|
|
897
882
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
883
|
+
if (byte1 === 0) {
|
|
884
|
+
break; // NULL
|
|
885
|
+
}
|
|
901
886
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
887
|
+
if ((byte1 & 0x80) === 0) { // 1-byte
|
|
888
|
+
codePoint = byte1;
|
|
889
|
+
} else if ((byte1 & 0xe0) === 0xc0) { // 2-byte
|
|
890
|
+
const byte2 = bytes[i++] & 0x3f;
|
|
891
|
+
codePoint = (((byte1 & 0x1f) << 6) | byte2);
|
|
892
|
+
} else if ((byte1 & 0xf0) === 0xe0) {
|
|
893
|
+
const byte2 = bytes[i++] & 0x3f;
|
|
894
|
+
const byte3 = bytes[i++] & 0x3f;
|
|
895
|
+
codePoint = (((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);
|
|
896
|
+
} else if ((byte1 & 0xf8) === 0xf0) {
|
|
897
|
+
const byte2 = bytes[i++] & 0x3f;
|
|
898
|
+
const byte3 = bytes[i++] & 0x3f;
|
|
899
|
+
const byte4 = bytes[i++] & 0x3f;
|
|
900
|
+
|
|
901
|
+
// this can be > 0xffff, so possibly generate surrogates
|
|
902
|
+
codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
|
|
903
|
+
if (codePoint > 0xffff) {
|
|
904
|
+
// codepoint &= ~0x10000;
|
|
905
|
+
codePoint -= 0x10000;
|
|
906
|
+
|
|
907
|
+
result += String.fromCharCode((codePoint >>> 10) & 0x3ff | 0xd800);
|
|
908
|
+
charCount++;
|
|
909
|
+
|
|
910
|
+
codePoint = 0xdc00 | codePoint & 0x3ff;
|
|
911
|
+
}
|
|
912
|
+
} else {
|
|
913
|
+
// FIXME: we're ignoring this
|
|
926
914
|
}
|
|
927
|
-
|
|
928
|
-
|
|
915
|
+
|
|
916
|
+
charCount++;
|
|
917
|
+
result += String.fromCharCode(codePoint);
|
|
918
|
+
|
|
929
919
|
}
|
|
930
920
|
|
|
931
|
-
|
|
932
|
-
result += String.fromCharCode(codePoint);
|
|
921
|
+
this.position = i;
|
|
933
922
|
|
|
923
|
+
return result;
|
|
934
924
|
}
|
|
935
925
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
926
|
+
/**
|
|
927
|
+
*
|
|
928
|
+
* @param {string} string
|
|
929
|
+
*/
|
|
930
|
+
writeASCIIString(string) {
|
|
931
|
+
const char_count = string.length;
|
|
940
932
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
* @param {string} string
|
|
944
|
-
*/
|
|
945
|
-
BinaryBuffer.prototype.writeASCIIString = function (string) {
|
|
946
|
-
const char_count = string.length;
|
|
933
|
+
const start = this.position;
|
|
934
|
+
const end = start + char_count;
|
|
947
935
|
|
|
948
|
-
|
|
949
|
-
const end = start + char_count;
|
|
936
|
+
this.ensureCapacity(end);
|
|
950
937
|
|
|
951
|
-
|
|
938
|
+
for (let i = 0; i < char_count; i++) {
|
|
939
|
+
const char_code = string.charCodeAt(i);
|
|
952
940
|
|
|
953
|
-
|
|
954
|
-
|
|
941
|
+
if (char_code > 0xFF) {
|
|
942
|
+
throw new Error(`Character ${String.fromCharCode(char_code)} can\'t be represented by a US-ASCII byte.`);
|
|
943
|
+
}
|
|
955
944
|
|
|
956
|
-
|
|
957
|
-
throw new Error(`Character ${String.fromCharCode(char_code)} can\'t be represented by a US-ASCII byte.`);
|
|
945
|
+
this.__data_uint8[start + i] = char_code;
|
|
958
946
|
}
|
|
959
947
|
|
|
960
|
-
this.
|
|
948
|
+
this.position = end;
|
|
961
949
|
}
|
|
962
950
|
|
|
963
|
-
|
|
964
|
-
|
|
951
|
+
/**
|
|
952
|
+
*
|
|
953
|
+
* @param {number} length
|
|
954
|
+
* @returns {string}
|
|
955
|
+
*/
|
|
956
|
+
readASCIICharacters(length) {
|
|
957
|
+
let result = "";
|
|
965
958
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
* @param {number} length
|
|
969
|
-
* @returns {string}
|
|
970
|
-
*/
|
|
971
|
-
BinaryBuffer.prototype.readASCIICharacters = function (length) {
|
|
972
|
-
let result = "";
|
|
959
|
+
for (let i = 0; i < length; i++) {
|
|
960
|
+
const code = this.readUint8();
|
|
973
961
|
|
|
974
|
-
|
|
975
|
-
|
|
962
|
+
result += String.fromCharCode(code);
|
|
963
|
+
}
|
|
976
964
|
|
|
977
|
-
result
|
|
965
|
+
return result;
|
|
978
966
|
}
|
|
979
967
|
|
|
980
|
-
|
|
981
|
-
|
|
968
|
+
/**
|
|
969
|
+
*
|
|
970
|
+
* @param {ArrayBuffer} v
|
|
971
|
+
* @return {BinaryBuffer}
|
|
972
|
+
*/
|
|
973
|
+
static fromArrayBuffer(v) {
|
|
974
|
+
const r = new BinaryBuffer();
|
|
982
975
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
* @returns {string} Copied value
|
|
988
|
-
*/
|
|
989
|
-
BinaryBuffer.copyUTF8String = function (source, target) {
|
|
990
|
-
const v = source.readUTF8String();
|
|
976
|
+
r.fromArrayBuffer(v);
|
|
977
|
+
|
|
978
|
+
return r;
|
|
979
|
+
}
|
|
991
980
|
|
|
992
|
-
|
|
981
|
+
/**
|
|
982
|
+
*
|
|
983
|
+
* @param {BinaryBuffer} source
|
|
984
|
+
* @param {BinaryBuffer} target
|
|
985
|
+
* @returns {string} Copied value
|
|
986
|
+
*/
|
|
987
|
+
static copyUTF8String(source, target) {
|
|
988
|
+
const v = source.readUTF8String();
|
|
993
989
|
|
|
994
|
-
|
|
995
|
-
};
|
|
996
|
-
/**
|
|
997
|
-
*
|
|
998
|
-
* @param {BinaryBuffer} source
|
|
999
|
-
* @param {BinaryBuffer} target
|
|
1000
|
-
* @returns {number} Copied value
|
|
1001
|
-
*/
|
|
1002
|
-
BinaryBuffer.copyUintVar = function (source, target) {
|
|
1003
|
-
const v = source.readUintVar();
|
|
990
|
+
target.writeUTF8String(v);
|
|
1004
991
|
|
|
1005
|
-
|
|
992
|
+
return v;
|
|
993
|
+
}
|
|
1006
994
|
|
|
1007
|
-
|
|
1008
|
-
|
|
995
|
+
/**
|
|
996
|
+
*
|
|
997
|
+
* @param {BinaryBuffer} source
|
|
998
|
+
* @param {BinaryBuffer} target
|
|
999
|
+
* @returns {number} Copied value
|
|
1000
|
+
*/
|
|
1001
|
+
static copyUintVar(source, target) {
|
|
1002
|
+
const v = source.readUintVar();
|
|
1009
1003
|
|
|
1010
|
-
|
|
1011
|
-
*
|
|
1012
|
-
* @param {BinaryBuffer} source
|
|
1013
|
-
* @param {BinaryBuffer} target
|
|
1014
|
-
* @returns {number} Copied value
|
|
1015
|
-
*/
|
|
1016
|
-
BinaryBuffer.copyUint8 = function (source, target) {
|
|
1017
|
-
const v = source.readUint8();
|
|
1004
|
+
target.writeUintVar(v);
|
|
1018
1005
|
|
|
1019
|
-
|
|
1006
|
+
return v;
|
|
1007
|
+
}
|
|
1020
1008
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1009
|
+
/**
|
|
1010
|
+
*
|
|
1011
|
+
* @param {BinaryBuffer} source
|
|
1012
|
+
* @param {BinaryBuffer} target
|
|
1013
|
+
* @returns {number} Copied value
|
|
1014
|
+
*/
|
|
1015
|
+
static copyUint8(source, target) {
|
|
1016
|
+
const v = source.readUint8();
|
|
1023
1017
|
|
|
1024
|
-
|
|
1025
|
-
*
|
|
1026
|
-
* @param {BinaryBuffer} source
|
|
1027
|
-
* @param {BinaryBuffer} target
|
|
1028
|
-
* @returns {number} Copied value
|
|
1029
|
-
*/
|
|
1030
|
-
BinaryBuffer.copyUint16 = function (source, target) {
|
|
1031
|
-
const v = source.readUint16();
|
|
1018
|
+
target.writeUint8(v);
|
|
1032
1019
|
|
|
1033
|
-
|
|
1020
|
+
return v;
|
|
1021
|
+
}
|
|
1034
1022
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
BinaryBuffer.copyUint32 = function (source, target) {
|
|
1044
|
-
const v = source.readUint32();
|
|
1023
|
+
/**
|
|
1024
|
+
*
|
|
1025
|
+
* @param {BinaryBuffer} source
|
|
1026
|
+
* @param {BinaryBuffer} target
|
|
1027
|
+
* @returns {number} Copied value
|
|
1028
|
+
*/
|
|
1029
|
+
static copyUint16(source, target) {
|
|
1030
|
+
const v = source.readUint16();
|
|
1045
1031
|
|
|
1046
|
-
|
|
1032
|
+
target.writeUint16(v);
|
|
1047
1033
|
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1034
|
+
return v;
|
|
1035
|
+
}
|
|
1050
1036
|
|
|
1051
|
-
/**
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1037
|
+
/**
|
|
1038
|
+
*
|
|
1039
|
+
* @param {BinaryBuffer} source
|
|
1040
|
+
* @param {BinaryBuffer} target
|
|
1041
|
+
* @returns {number} Copied value
|
|
1042
|
+
*/
|
|
1043
|
+
static copyUint32(source, target) {
|
|
1044
|
+
const v = source.readUint32();
|
|
1059
1045
|
|
|
1060
|
-
|
|
1046
|
+
target.writeUint32(v);
|
|
1061
1047
|
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1048
|
+
return v;
|
|
1049
|
+
}
|
|
1064
1050
|
|
|
1065
|
-
/**
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1051
|
+
/**
|
|
1052
|
+
*
|
|
1053
|
+
* @param {BinaryBuffer} source
|
|
1054
|
+
* @param {BinaryBuffer} target
|
|
1055
|
+
* @returns {number} Copied value
|
|
1056
|
+
*/
|
|
1057
|
+
static copyFloat32(source, target) {
|
|
1058
|
+
const v = source.readFloat32();
|
|
1073
1059
|
|
|
1074
|
-
|
|
1060
|
+
target.writeFloat32(v);
|
|
1075
1061
|
|
|
1076
|
-
|
|
1077
|
-
}
|
|
1062
|
+
return v;
|
|
1063
|
+
}
|
|
1078
1064
|
|
|
1079
|
-
/**
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1065
|
+
/**
|
|
1066
|
+
*
|
|
1067
|
+
* @param {BinaryBuffer} source
|
|
1068
|
+
* @param {BinaryBuffer} target
|
|
1069
|
+
* @returns {number} Copied value
|
|
1070
|
+
*/
|
|
1071
|
+
static copyFloat64(source, target) {
|
|
1072
|
+
const v = source.readFloat64();
|
|
1087
1073
|
|
|
1088
|
-
|
|
1074
|
+
target.writeFloat64(v);
|
|
1089
1075
|
|
|
1090
|
-
|
|
1076
|
+
return v;
|
|
1077
|
+
}
|
|
1091
1078
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1079
|
+
/**
|
|
1080
|
+
*
|
|
1081
|
+
* @param {BinaryBuffer} source
|
|
1082
|
+
* @param {BinaryBuffer} target
|
|
1083
|
+
* @param {number} length
|
|
1084
|
+
*/
|
|
1085
|
+
static copyBytes(source, target, length) {
|
|
1086
|
+
const temp = new Uint8Array(length);
|
|
1087
|
+
|
|
1088
|
+
source.readBytes(temp, 0, length);
|
|
1094
1089
|
|
|
1090
|
+
target.writeBytes(temp, 0, length);
|
|
1095
1091
|
|
|
1096
|
-
|
|
1092
|
+
return temp;
|
|
1093
|
+
}
|
|
1094
|
+
}
|