@loaders.gl/netcdf 3.3.0-alpha.5 → 3.3.0-alpha.7

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/dist/es5/index.js CHANGED
@@ -3,20 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "NetCDFReader", {
6
+ Object.defineProperty(exports, "NetCDFLoader", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _netcdfReader.NetCDFReader;
9
+ return _netcdfLoader.NetCDFLoader;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "NetCDFLoader", {
12
+ Object.defineProperty(exports, "NetCDFReader", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _netcdfLoader.NetCDFLoader;
15
+ return _netcdfReader.NetCDFReader;
16
16
  }
17
17
  });
18
-
19
18
  var _netcdfReader = require("./netcdfjs/netcdf-reader");
20
-
21
19
  var _netcdfLoader = require("./netcdf-loader");
22
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA","sourcesContent":["export {NetCDFReader} from './netcdfjs/netcdf-reader';\n\nexport {NetCDFLoader} from './netcdf-loader';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export {NetCDFReader} from './netcdfjs/netcdf-reader';\n\nexport {NetCDFLoader} from './netcdf-loader';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAEA"}
@@ -1,21 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.IOBuffer = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
11
  var DEFAULT_BYTE_LENGTH = 1024 * 8;
17
-
18
12
  var IOBuffer = function () {
13
+
19
14
  function IOBuffer() {
20
15
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BYTE_LENGTH;
21
16
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -33,32 +28,26 @@ var IOBuffer = function () {
33
28
  (0, _defineProperty2.default)(this, "textDecoder", new TextDecoder());
34
29
  (0, _defineProperty2.default)(this, "textEncoder", new TextEncoder());
35
30
  var dataIsGiven = false;
36
-
37
31
  if (typeof data === 'number') {
38
32
  data = new ArrayBuffer(data);
39
33
  } else {
40
34
  dataIsGiven = true;
41
35
  this.lastWrittenByte = data.byteLength;
42
36
  }
43
-
44
37
  var offset = options.offset ? options.offset >>> 0 : 0;
45
38
  var byteLength = data.byteLength - offset;
46
39
  var dvOffset = offset;
47
-
48
40
  if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
49
41
  if (data.byteLength !== data.buffer.byteLength) {
50
42
  dvOffset = data.byteOffset + offset;
51
43
  }
52
-
53
44
  data = data.buffer;
54
45
  }
55
-
56
46
  if (dataIsGiven) {
57
47
  this.lastWrittenByte = byteLength;
58
48
  } else {
59
49
  this.lastWrittenByte = 0;
60
50
  }
61
-
62
51
  this.buffer = data;
63
52
  this.length = byteLength;
64
53
  this.byteLength = byteLength;
@@ -72,87 +61,108 @@ var IOBuffer = function () {
72
61
 
73
62
  (0, _createClass2.default)(IOBuffer, [{
74
63
  key: "available",
75
- value: function available() {
64
+ value:
65
+ function available() {
76
66
  var byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
77
67
  return this.offset + byteLength <= this.length;
78
68
  }
69
+
79
70
  }, {
80
71
  key: "isLittleEndian",
81
- value: function isLittleEndian() {
72
+ value:
73
+ function isLittleEndian() {
82
74
  return this.littleEndian;
83
75
  }
76
+
84
77
  }, {
85
78
  key: "setLittleEndian",
86
- value: function setLittleEndian() {
79
+ value:
80
+ function setLittleEndian() {
87
81
  this.littleEndian = true;
88
82
  return this;
89
83
  }
84
+
90
85
  }, {
91
86
  key: "isBigEndian",
92
- value: function isBigEndian() {
87
+ value:
88
+ function isBigEndian() {
93
89
  return !this.littleEndian;
94
90
  }
91
+
95
92
  }, {
96
93
  key: "setBigEndian",
97
- value: function setBigEndian() {
94
+ value:
95
+ function setBigEndian() {
98
96
  this.littleEndian = false;
99
97
  return this;
100
98
  }
99
+
101
100
  }, {
102
101
  key: "skip",
103
- value: function skip() {
102
+ value:
103
+ function skip() {
104
104
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
105
105
  this.offset += n;
106
106
  return this;
107
107
  }
108
+
108
109
  }, {
109
110
  key: "seek",
110
- value: function seek(offset) {
111
+ value:
112
+ function seek(offset) {
111
113
  this.offset = offset;
112
114
  return this;
113
115
  }
116
+
114
117
  }, {
115
118
  key: "mark",
116
- value: function mark() {
119
+ value:
120
+ function mark() {
117
121
  this._mark = this.offset;
118
122
  return this;
119
123
  }
124
+
120
125
  }, {
121
126
  key: "reset",
122
- value: function reset() {
127
+ value:
128
+ function reset() {
123
129
  this.offset = this._mark;
124
130
  return this;
125
131
  }
132
+
126
133
  }, {
127
134
  key: "pushMark",
128
- value: function pushMark() {
135
+ value:
136
+ function pushMark() {
129
137
  this._marks.push(this.offset);
130
-
131
138
  return this;
132
139
  }
140
+
133
141
  }, {
134
142
  key: "popMark",
135
- value: function popMark() {
143
+ value:
144
+ function popMark() {
136
145
  var offset = this._marks.pop();
137
-
138
146
  if (offset === undefined) {
139
147
  throw new Error('Mark stack empty');
140
148
  }
141
-
142
149
  this.seek(offset);
143
150
  return this;
144
151
  }
152
+
145
153
  }, {
146
154
  key: "rewind",
147
- value: function rewind() {
155
+ value:
156
+ function rewind() {
148
157
  this.offset = 0;
149
158
  return this;
150
159
  }
160
+
151
161
  }, {
152
162
  key: "ensureAvailable",
153
- value: function ensureAvailable() {
163
+ value:
164
+ function ensureAvailable() {
154
165
  var byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
155
-
156
166
  if (!this.available(byteLength)) {
157
167
  var lengthNeeded = this.offset + byteLength;
158
168
  var newLength = lengthNeeded * 2;
@@ -162,264 +172,279 @@ var IOBuffer = function () {
162
172
  this.length = this.byteLength = newLength;
163
173
  this._data = new DataView(this.buffer);
164
174
  }
165
-
166
175
  return this;
167
176
  }
177
+
168
178
  }, {
169
179
  key: "readBoolean",
170
- value: function readBoolean() {
180
+ value:
181
+ function readBoolean() {
171
182
  return this.readUint8() !== 0;
172
183
  }
184
+
173
185
  }, {
174
186
  key: "readInt8",
175
- value: function readInt8() {
187
+ value:
188
+ function readInt8() {
176
189
  return this._data.getInt8(this.offset++);
177
190
  }
191
+
178
192
  }, {
179
193
  key: "readUint8",
180
- value: function readUint8() {
194
+ value:
195
+ function readUint8() {
181
196
  return this._data.getUint8(this.offset++);
182
197
  }
198
+
183
199
  }, {
184
200
  key: "readByte",
185
- value: function readByte() {
201
+ value:
202
+ function readByte() {
186
203
  return this.readUint8();
187
204
  }
205
+
188
206
  }, {
189
207
  key: "readBytes",
190
- value: function readBytes() {
208
+ value:
209
+ function readBytes() {
191
210
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
192
211
  var bytes = new Uint8Array(n);
193
-
194
212
  for (var i = 0; i < n; i++) {
195
213
  bytes[i] = this.readByte();
196
214
  }
197
-
198
215
  return bytes;
199
216
  }
217
+
200
218
  }, {
201
219
  key: "readInt16",
202
- value: function readInt16() {
220
+ value:
221
+ function readInt16() {
203
222
  var value = this._data.getInt16(this.offset, this.littleEndian);
204
-
205
223
  this.offset += 2;
206
224
  return value;
207
225
  }
226
+
208
227
  }, {
209
228
  key: "readUint16",
210
- value: function readUint16() {
229
+ value:
230
+ function readUint16() {
211
231
  var value = this._data.getUint16(this.offset, this.littleEndian);
212
-
213
232
  this.offset += 2;
214
233
  return value;
215
234
  }
235
+
216
236
  }, {
217
237
  key: "readInt32",
218
- value: function readInt32() {
238
+ value:
239
+ function readInt32() {
219
240
  var value = this._data.getInt32(this.offset, this.littleEndian);
220
-
221
241
  this.offset += 4;
222
242
  return value;
223
243
  }
244
+
224
245
  }, {
225
246
  key: "readUint32",
226
- value: function readUint32() {
247
+ value:
248
+ function readUint32() {
227
249
  var value = this._data.getUint32(this.offset, this.littleEndian);
228
-
229
250
  this.offset += 4;
230
251
  return value;
231
252
  }
253
+
232
254
  }, {
233
255
  key: "readFloat32",
234
- value: function readFloat32() {
256
+ value:
257
+ function readFloat32() {
235
258
  var value = this._data.getFloat32(this.offset, this.littleEndian);
236
-
237
259
  this.offset += 4;
238
260
  return value;
239
261
  }
262
+
240
263
  }, {
241
264
  key: "readFloat64",
242
- value: function readFloat64() {
265
+ value:
266
+ function readFloat64() {
243
267
  var value = this._data.getFloat64(this.offset, this.littleEndian);
244
-
245
268
  this.offset += 8;
246
269
  return value;
247
270
  }
271
+
248
272
  }, {
249
273
  key: "readChar",
250
- value: function readChar() {
274
+ value:
275
+ function readChar() {
251
276
  return String.fromCharCode(this.readInt8());
252
277
  }
278
+
253
279
  }, {
254
280
  key: "readChars",
255
- value: function readChars() {
281
+ value:
282
+ function readChars() {
256
283
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
257
284
  var result = '';
258
-
259
285
  for (var i = 0; i < n; i++) {
260
286
  result += this.readChar();
261
287
  }
262
-
263
288
  return result;
264
289
  }
290
+
265
291
  }, {
266
292
  key: "readUtf8",
267
- value: function readUtf8() {
293
+ value:
294
+ function readUtf8() {
268
295
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
269
296
  return this.textDecoder.decode(this.readBytes(n));
270
297
  }
298
+
271
299
  }, {
272
300
  key: "writeBoolean",
273
- value: function writeBoolean(value) {
301
+ value:
302
+ function writeBoolean(value) {
274
303
  this.writeUint8(value ? 0xff : 0x00);
275
304
  return this;
276
305
  }
306
+
277
307
  }, {
278
308
  key: "writeInt8",
279
- value: function writeInt8(value) {
309
+ value:
310
+ function writeInt8(value) {
280
311
  this.ensureAvailable(1);
281
-
282
312
  this._data.setInt8(this.offset++, value);
283
-
284
313
  this._updateLastWrittenByte();
285
-
286
314
  return this;
287
315
  }
316
+
288
317
  }, {
289
318
  key: "writeUint8",
290
- value: function writeUint8(value) {
319
+ value:
320
+ function writeUint8(value) {
291
321
  this.ensureAvailable(1);
292
-
293
322
  this._data.setUint8(this.offset++, value);
294
-
295
323
  this._updateLastWrittenByte();
296
-
297
324
  return this;
298
325
  }
326
+
299
327
  }, {
300
328
  key: "writeByte",
301
- value: function writeByte(value) {
329
+ value:
330
+ function writeByte(value) {
302
331
  return this.writeUint8(value);
303
332
  }
333
+
304
334
  }, {
305
335
  key: "writeBytes",
306
- value: function writeBytes(bytes) {
336
+ value:
337
+ function writeBytes(bytes) {
307
338
  this.ensureAvailable(bytes.length);
308
-
309
339
  for (var i = 0; i < bytes.length; i++) {
310
340
  this._data.setUint8(this.offset++, bytes[i]);
311
341
  }
312
-
313
342
  this._updateLastWrittenByte();
314
-
315
343
  return this;
316
344
  }
345
+
317
346
  }, {
318
347
  key: "writeInt16",
319
- value: function writeInt16(value) {
348
+ value:
349
+ function writeInt16(value) {
320
350
  this.ensureAvailable(2);
321
-
322
351
  this._data.setInt16(this.offset, value, this.littleEndian);
323
-
324
352
  this.offset += 2;
325
-
326
353
  this._updateLastWrittenByte();
327
-
328
354
  return this;
329
355
  }
356
+
330
357
  }, {
331
358
  key: "writeUint16",
332
- value: function writeUint16(value) {
359
+ value:
360
+ function writeUint16(value) {
333
361
  this.ensureAvailable(2);
334
-
335
362
  this._data.setUint16(this.offset, value, this.littleEndian);
336
-
337
363
  this.offset += 2;
338
-
339
364
  this._updateLastWrittenByte();
340
-
341
365
  return this;
342
366
  }
367
+
343
368
  }, {
344
369
  key: "writeInt32",
345
- value: function writeInt32(value) {
370
+ value:
371
+ function writeInt32(value) {
346
372
  this.ensureAvailable(4);
347
-
348
373
  this._data.setInt32(this.offset, value, this.littleEndian);
349
-
350
374
  this.offset += 4;
351
-
352
375
  this._updateLastWrittenByte();
353
-
354
376
  return this;
355
377
  }
378
+
356
379
  }, {
357
380
  key: "writeUint32",
358
- value: function writeUint32(value) {
381
+ value:
382
+ function writeUint32(value) {
359
383
  this.ensureAvailable(4);
360
-
361
384
  this._data.setUint32(this.offset, value, this.littleEndian);
362
-
363
385
  this.offset += 4;
364
-
365
386
  this._updateLastWrittenByte();
366
-
367
387
  return this;
368
388
  }
389
+
369
390
  }, {
370
391
  key: "writeFloat32",
371
- value: function writeFloat32(value) {
392
+ value:
393
+ function writeFloat32(value) {
372
394
  this.ensureAvailable(4);
373
-
374
395
  this._data.setFloat32(this.offset, value, this.littleEndian);
375
-
376
396
  this.offset += 4;
377
-
378
397
  this._updateLastWrittenByte();
379
-
380
398
  return this;
381
399
  }
400
+
382
401
  }, {
383
402
  key: "writeFloat64",
384
- value: function writeFloat64(value) {
403
+ value:
404
+ function writeFloat64(value) {
385
405
  this.ensureAvailable(8);
386
-
387
406
  this._data.setFloat64(this.offset, value, this.littleEndian);
388
-
389
407
  this.offset += 8;
390
-
391
408
  this._updateLastWrittenByte();
392
-
393
409
  return this;
394
410
  }
411
+
395
412
  }, {
396
413
  key: "writeChar",
397
- value: function writeChar(str) {
414
+ value:
415
+ function writeChar(str) {
398
416
  return this.writeUint8(str.charCodeAt(0));
399
417
  }
418
+
400
419
  }, {
401
420
  key: "writeChars",
402
- value: function writeChars(str) {
421
+ value:
422
+ function writeChars(str) {
403
423
  for (var i = 0; i < str.length; i++) {
404
424
  this.writeUint8(str.charCodeAt(i));
405
425
  }
406
-
407
426
  return this;
408
427
  }
428
+
409
429
  }, {
410
430
  key: "writeUtf8",
411
- value: function writeUtf8(str) {
431
+ value:
432
+ function writeUtf8(str) {
412
433
  var bytes = this.textEncoder.encode(str);
413
434
  return this.writeBytes(bytes);
414
435
  }
436
+
415
437
  }, {
416
438
  key: "toArray",
417
- value: function toArray() {
439
+ value:
440
+ function toArray() {
418
441
  return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
419
442
  }
443
+
420
444
  }, {
421
445
  key: "_updateLastWrittenByte",
422
- value: function _updateLastWrittenByte() {
446
+ value:
447
+ function _updateLastWrittenByte() {
423
448
  if (this.offset > this.lastWrittenByte) {
424
449
  this.lastWrittenByte = this.offset;
425
450
  }
@@ -427,6 +452,5 @@ var IOBuffer = function () {
427
452
  }]);
428
453
  return IOBuffer;
429
454
  }();
430
-
431
455
  exports.IOBuffer = IOBuffer;
432
456
  //# sourceMappingURL=iobuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/iobuffer/iobuffer.ts"],"names":["DEFAULT_BYTE_LENGTH","IOBuffer","data","options","TextDecoder","TextEncoder","dataIsGiven","ArrayBuffer","lastWrittenByte","byteLength","offset","dvOffset","isView","buffer","byteOffset","length","littleEndian","_data","DataView","_mark","_marks","n","push","pop","undefined","Error","seek","available","lengthNeeded","newLength","newArray","Uint8Array","set","readUint8","getInt8","getUint8","bytes","i","readByte","value","getInt16","getUint16","getInt32","getUint32","getFloat32","getFloat64","String","fromCharCode","readInt8","result","readChar","textDecoder","decode","readBytes","writeUint8","ensureAvailable","setInt8","_updateLastWrittenByte","setUint8","setInt16","setUint16","setInt32","setUint32","setFloat32","setFloat64","str","charCodeAt","textEncoder","encode","writeBytes"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAMA,mBAAmB,GAAG,OAAO,CAAnC;;IAWaC,Q;AA4CX,sBAAyF;AAAA,QAAtEC,IAAsE,uEAApDF,mBAAoD;AAAA,QAA/BG,OAA+B,uEAAJ,EAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uDAXnE,IAAIC,WAAJ,EAW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P;AACD;;;WAMD,mBAAiBQ,GAAjB,EAAoC;AAClC,aAAO,KAAKX,UAAL,CAAgBW,GAAG,CAACC,UAAJ,CAAe,CAAf,CAAhB,CAAP;AACD;;;WAMD,oBAAkBD,GAAlB,EAAqC;AACnC,WAAK,IAAI5B,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG4B,GAAG,CAAClD,MAAxB,EAAgCsB,CAAC,EAAjC,EAAqC;AACnC,aAAKiB,UAAL,CAAgBW,GAAG,CAACC,UAAJ,CAAe7B,CAAf,CAAhB;AACD;;AACD,aAAO,IAAP;AACD;;;WAMD,mBAAiB4B,GAAjB,EAAoC;AAClC,UAAM7B,KAAK,GAAG,KAAK+B,WAAL,CAAiBC,MAAjB,CAAwBH,GAAxB,CAAd;AACA,aAAO,KAAKI,UAAL,CAAgBjC,KAAhB,CAAP;AACD;;;WAOD,mBAA6B;AAC3B,aAAO,IAAIL,UAAJ,CAAe,KAAKlB,MAApB,EAA4B,KAAKC,UAAjC,EAA6C,KAAKN,eAAlD,CAAP;AACD;;;WAMD,kCAAuC;AACrC,UAAI,KAAKE,MAAL,GAAc,KAAKF,eAAvB,EAAwC;AACtC,aAAKA,eAAL,GAAuB,KAAKE,MAA5B;AACD;AACF","sourcesContent":["const DEFAULT_BYTE_LENGTH = 1024 * 8;\n\ntype InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;\n\ninterface IOBufferOptions {\n /**\n * Ignore the first n bytes of the ArrayBuffer.\n */\n offset?: number;\n}\n\nexport class IOBuffer {\n /**\n * Reference to the internal ArrayBuffer object.\n */\n public buffer: ArrayBufferLike;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public byteLength: number;\n\n /**\n * Byte offset of the internal ArrayBuffer.\n */\n public byteOffset: number;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public length: number;\n\n /**\n * The current offset of the buffer's pointer.\n */\n public offset: number;\n\n private lastWrittenByte: number;\n private littleEndian: boolean;\n\n private _data: DataView;\n private _mark: number;\n private _marks: number[];\n\n private textDecoder = new TextDecoder();\n private textEncoder = new TextEncoder();\n\n /**\n * @param data - The data to construct the IOBuffer with.\n * If data is a number, it will be the new buffer's length<br>\n * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>\n * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n * @param options\n */\n public constructor(data: InputData = DEFAULT_BYTE_LENGTH, options: IOBufferOptions = {}) {\n let dataIsGiven = false;\n if (typeof data === 'number') {\n data = new ArrayBuffer(data);\n } else {\n dataIsGiven = true;\n this.lastWrittenByte = data.byteLength;\n }\n\n const offset = options.offset ? options.offset >>> 0 : 0;\n const byteLength = data.byteLength - offset;\n let dvOffset = offset;\n if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset;\n }\n data = data.buffer;\n }\n if (dataIsGiven) {\n this.lastWrittenByte = byteLength;\n } else {\n this.lastWrittenByte = 0;\n }\n this.buffer = data;\n this.length = byteLength;\n this.byteLength = byteLength;\n this.byteOffset = dvOffset;\n this.offset = 0;\n this.littleEndian = true;\n this._data = new DataView(this.buffer, dvOffset, byteLength);\n this._mark = 0;\n this._marks = [];\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more\n * bytes after the offset.\n * @param byteLength - The needed memory in bytes.\n * @returns `true` if there is sufficient space and `false` otherwise.\n */\n public available(byteLength = 1): boolean {\n return this.offset + byteLength <= this.length;\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte\n * values.\n * @returns `true` if little-endian mode is used, `false` otherwise.\n */\n public isLittleEndian(): boolean {\n return this.littleEndian;\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values.\n */\n public setLittleEndian(): this {\n this.littleEndian = true;\n return this;\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values.\n * @returns `true` if big-endian mode is used, `false` otherwise.\n */\n public isBigEndian(): boolean {\n return !this.littleEndian;\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values.\n */\n public setBigEndian(): this {\n this.littleEndian = false;\n return this;\n }\n\n /**\n * Move the pointer n bytes forward.\n * @param n - Number of bytes to skip.\n */\n public skip(n = 1): this {\n this.offset += n;\n return this;\n }\n\n /**\n * Move the pointer to the given offset.\n * @param offset\n */\n public seek(offset: number): this {\n this.offset = offset;\n return this;\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n */\n public mark(): this {\n this._mark = this.offset;\n return this;\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark.\n * @see {@link IOBuffer#mark}\n */\n public reset(): this {\n this.offset = this._mark;\n return this;\n }\n\n /**\n * Push the current pointer offset to the mark stack.\n * @see {@link IOBuffer#popMark}\n */\n public pushMark(): this {\n this._marks.push(this.offset);\n return this;\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current\n * pointer offset to the popped value.\n * @see {@link IOBuffer#pushMark}\n */\n public popMark(): this {\n const offset = this._marks.pop();\n if (offset === undefined) {\n throw new Error('Mark stack empty');\n }\n this.seek(offset);\n return this;\n }\n\n /**\n * Move the pointer offset back to 0.\n */\n public rewind(): this {\n this.offset = 0;\n return this;\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at\n * the current pointer offset.\n * If the buffer's memory is insufficient, this method will create a new\n * buffer (a copy) with a length that is twice (byteLength + current offset).\n * @param byteLength\n */\n public ensureAvailable(byteLength = 1): this {\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength;\n const newLength = lengthNeeded * 2;\n const newArray = new Uint8Array(newLength);\n newArray.set(new Uint8Array(this.buffer));\n this.buffer = newArray.buffer;\n this.length = this.byteLength = newLength;\n this._data = new DataView(this.buffer);\n }\n return this;\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise.\n * Moves pointer forward by one byte.\n */\n public readBoolean(): boolean {\n return this.readUint8() !== 0;\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward by 1 byte.\n */\n public readInt8(): number {\n return this._data.getInt8(this.offset++);\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n */\n public readUint8(): number {\n return this._data.getUint8(this.offset++);\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}.\n */\n public readByte(): number {\n return this.readUint8();\n }\n\n /**\n * Read `n` bytes and move pointer forward by `n` bytes.\n */\n public readBytes(n = 1): Uint8Array {\n const bytes = new Uint8Array(n);\n for (let i = 0; i < n; i++) {\n bytes[i] = this.readByte();\n }\n return bytes;\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n */\n public readInt16(): number {\n const value = this._data.getInt16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n */\n public readUint16(): number {\n const value = this._data.getUint16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n */\n public readInt32(): number {\n const value = this._data.getInt32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n */\n public readUint32(): number {\n const value = this._data.getUint32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward by 4 bytes.\n */\n public readFloat32(): number {\n const value = this._data.getFloat32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward by 8 bytes.\n */\n public readFloat64(): number {\n const value = this._data.getFloat64(this.offset, this.littleEndian);\n this.offset += 8;\n return value;\n }\n\n /**\n * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n */\n public readChar(): string {\n return String.fromCharCode(this.readInt8());\n }\n\n /**\n * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n */\n public readChars(n = 1): string {\n let result = '';\n for (let i = 0; i < n; i++) {\n result += this.readChar();\n }\n return result;\n }\n\n /**\n * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n * forward by `n` bytes.\n */\n public readUtf8(n = 1): string {\n return this.textDecoder.decode(this.readBytes(n));\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n * forward by 1 byte.\n */\n public writeBoolean(value: unknown): this {\n this.writeUint8(value ? 0xff : 0x00);\n return this;\n }\n\n /**\n * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n */\n public writeInt8(value: number): this {\n this.ensureAvailable(1);\n this._data.setInt8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n * byte.\n */\n public writeUint8(value: number): this {\n this.ensureAvailable(1);\n this._data.setUint8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}.\n */\n public writeByte(value: number): this {\n return this.writeUint8(value);\n }\n\n /**\n * Write all elements of `bytes` as uint8 values and move pointer forward by\n * `bytes.length` bytes.\n */\n public writeBytes(bytes: ArrayLike<number>): this {\n this.ensureAvailable(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i]);\n }\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit signed integer and move pointer forward by 2\n * bytes.\n */\n public writeInt16(value: number): this {\n this.ensureAvailable(2);\n this._data.setInt16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n * bytes.\n */\n public writeUint16(value: number): this {\n this.ensureAvailable(2);\n this._data.setUint16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit signed integer and move pointer forward by 4\n * bytes.\n */\n public writeInt32(value: number): this {\n this.ensureAvailable(4);\n this._data.setInt32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n * bytes.\n */\n public writeUint32(value: number): this {\n this.ensureAvailable(4);\n this._data.setUint32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit floating number and move pointer forward by 4\n * bytes.\n */\n public writeFloat32(value: number): this {\n this.ensureAvailable(4);\n this._data.setFloat32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 64-bit floating number and move pointer forward by 8\n * bytes.\n */\n public writeFloat64(value: number): this {\n this.ensureAvailable(8);\n this._data.setFloat64(this.offset, value, this.littleEndian);\n this.offset += 8;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n * and move pointer forward by 1 byte.\n */\n public writeChar(str: string): this {\n return this.writeUint8(str.charCodeAt(0));\n }\n\n /**\n * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n * and move pointer forward by `str.length` bytes.\n */\n public writeChars(str: string): this {\n for (let i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i));\n }\n return this;\n }\n\n /**\n * UTF-8 encode and write `str` to the current pointer offset and move pointer\n * forward according to the encoded length.\n */\n public writeUtf8(str: string): this {\n const bytes = this.textEncoder.encode(str);\n return this.writeBytes(bytes);\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n */\n public toArray(): Uint8Array {\n return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n private _updateLastWrittenByte(): void {\n if (this.offset > this.lastWrittenByte) {\n this.lastWrittenByte = this.offset;\n }\n }\n}\n"],"file":"iobuffer.js"}
1
+ {"version":3,"file":"iobuffer.js","names":["DEFAULT_BYTE_LENGTH","IOBuffer","data","options","TextDecoder","TextEncoder","dataIsGiven","ArrayBuffer","lastWrittenByte","byteLength","offset","dvOffset","isView","buffer","byteOffset","length","littleEndian","_data","DataView","_mark","_marks","n","push","pop","undefined","Error","seek","available","lengthNeeded","newLength","newArray","Uint8Array","set","readUint8","getInt8","getUint8","bytes","i","readByte","value","getInt16","getUint16","getInt32","getUint32","getFloat32","getFloat64","String","fromCharCode","readInt8","result","readChar","textDecoder","decode","readBytes","writeUint8","ensureAvailable","setInt8","_updateLastWrittenByte","setUint8","setInt16","setUint16","setInt32","setUint32","setFloat32","setFloat64","str","charCodeAt","textEncoder","encode","writeBytes"],"sources":["../../../src/iobuffer/iobuffer.ts"],"sourcesContent":["const DEFAULT_BYTE_LENGTH = 1024 * 8;\n\ntype InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;\n\ninterface IOBufferOptions {\n /**\n * Ignore the first n bytes of the ArrayBuffer.\n */\n offset?: number;\n}\n\nexport class IOBuffer {\n /**\n * Reference to the internal ArrayBuffer object.\n */\n public buffer: ArrayBufferLike;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public byteLength: number;\n\n /**\n * Byte offset of the internal ArrayBuffer.\n */\n public byteOffset: number;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public length: number;\n\n /**\n * The current offset of the buffer's pointer.\n */\n public offset: number;\n\n private lastWrittenByte: number;\n private littleEndian: boolean;\n\n private _data: DataView;\n private _mark: number;\n private _marks: number[];\n\n private textDecoder = new TextDecoder();\n private textEncoder = new TextEncoder();\n\n /**\n * @param data - The data to construct the IOBuffer with.\n * If data is a number, it will be the new buffer's length<br>\n * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>\n * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n * @param options\n */\n public constructor(data: InputData = DEFAULT_BYTE_LENGTH, options: IOBufferOptions = {}) {\n let dataIsGiven = false;\n if (typeof data === 'number') {\n data = new ArrayBuffer(data);\n } else {\n dataIsGiven = true;\n this.lastWrittenByte = data.byteLength;\n }\n\n const offset = options.offset ? options.offset >>> 0 : 0;\n const byteLength = data.byteLength - offset;\n let dvOffset = offset;\n if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset;\n }\n data = data.buffer;\n }\n if (dataIsGiven) {\n this.lastWrittenByte = byteLength;\n } else {\n this.lastWrittenByte = 0;\n }\n this.buffer = data;\n this.length = byteLength;\n this.byteLength = byteLength;\n this.byteOffset = dvOffset;\n this.offset = 0;\n this.littleEndian = true;\n this._data = new DataView(this.buffer, dvOffset, byteLength);\n this._mark = 0;\n this._marks = [];\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more\n * bytes after the offset.\n * @param byteLength - The needed memory in bytes.\n * @returns `true` if there is sufficient space and `false` otherwise.\n */\n public available(byteLength = 1): boolean {\n return this.offset + byteLength <= this.length;\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte\n * values.\n * @returns `true` if little-endian mode is used, `false` otherwise.\n */\n public isLittleEndian(): boolean {\n return this.littleEndian;\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values.\n */\n public setLittleEndian(): this {\n this.littleEndian = true;\n return this;\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values.\n * @returns `true` if big-endian mode is used, `false` otherwise.\n */\n public isBigEndian(): boolean {\n return !this.littleEndian;\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values.\n */\n public setBigEndian(): this {\n this.littleEndian = false;\n return this;\n }\n\n /**\n * Move the pointer n bytes forward.\n * @param n - Number of bytes to skip.\n */\n public skip(n = 1): this {\n this.offset += n;\n return this;\n }\n\n /**\n * Move the pointer to the given offset.\n * @param offset\n */\n public seek(offset: number): this {\n this.offset = offset;\n return this;\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n */\n public mark(): this {\n this._mark = this.offset;\n return this;\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark.\n * @see {@link IOBuffer#mark}\n */\n public reset(): this {\n this.offset = this._mark;\n return this;\n }\n\n /**\n * Push the current pointer offset to the mark stack.\n * @see {@link IOBuffer#popMark}\n */\n public pushMark(): this {\n this._marks.push(this.offset);\n return this;\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current\n * pointer offset to the popped value.\n * @see {@link IOBuffer#pushMark}\n */\n public popMark(): this {\n const offset = this._marks.pop();\n if (offset === undefined) {\n throw new Error('Mark stack empty');\n }\n this.seek(offset);\n return this;\n }\n\n /**\n * Move the pointer offset back to 0.\n */\n public rewind(): this {\n this.offset = 0;\n return this;\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at\n * the current pointer offset.\n * If the buffer's memory is insufficient, this method will create a new\n * buffer (a copy) with a length that is twice (byteLength + current offset).\n * @param byteLength\n */\n public ensureAvailable(byteLength = 1): this {\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength;\n const newLength = lengthNeeded * 2;\n const newArray = new Uint8Array(newLength);\n newArray.set(new Uint8Array(this.buffer));\n this.buffer = newArray.buffer;\n this.length = this.byteLength = newLength;\n this._data = new DataView(this.buffer);\n }\n return this;\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise.\n * Moves pointer forward by one byte.\n */\n public readBoolean(): boolean {\n return this.readUint8() !== 0;\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward by 1 byte.\n */\n public readInt8(): number {\n return this._data.getInt8(this.offset++);\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n */\n public readUint8(): number {\n return this._data.getUint8(this.offset++);\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}.\n */\n public readByte(): number {\n return this.readUint8();\n }\n\n /**\n * Read `n` bytes and move pointer forward by `n` bytes.\n */\n public readBytes(n = 1): Uint8Array {\n const bytes = new Uint8Array(n);\n for (let i = 0; i < n; i++) {\n bytes[i] = this.readByte();\n }\n return bytes;\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n */\n public readInt16(): number {\n const value = this._data.getInt16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n */\n public readUint16(): number {\n const value = this._data.getUint16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n */\n public readInt32(): number {\n const value = this._data.getInt32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n */\n public readUint32(): number {\n const value = this._data.getUint32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward by 4 bytes.\n */\n public readFloat32(): number {\n const value = this._data.getFloat32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward by 8 bytes.\n */\n public readFloat64(): number {\n const value = this._data.getFloat64(this.offset, this.littleEndian);\n this.offset += 8;\n return value;\n }\n\n /**\n * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n */\n public readChar(): string {\n return String.fromCharCode(this.readInt8());\n }\n\n /**\n * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n */\n public readChars(n = 1): string {\n let result = '';\n for (let i = 0; i < n; i++) {\n result += this.readChar();\n }\n return result;\n }\n\n /**\n * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n * forward by `n` bytes.\n */\n public readUtf8(n = 1): string {\n return this.textDecoder.decode(this.readBytes(n));\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n * forward by 1 byte.\n */\n public writeBoolean(value: unknown): this {\n this.writeUint8(value ? 0xff : 0x00);\n return this;\n }\n\n /**\n * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n */\n public writeInt8(value: number): this {\n this.ensureAvailable(1);\n this._data.setInt8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n * byte.\n */\n public writeUint8(value: number): this {\n this.ensureAvailable(1);\n this._data.setUint8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}.\n */\n public writeByte(value: number): this {\n return this.writeUint8(value);\n }\n\n /**\n * Write all elements of `bytes` as uint8 values and move pointer forward by\n * `bytes.length` bytes.\n */\n public writeBytes(bytes: ArrayLike<number>): this {\n this.ensureAvailable(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i]);\n }\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit signed integer and move pointer forward by 2\n * bytes.\n */\n public writeInt16(value: number): this {\n this.ensureAvailable(2);\n this._data.setInt16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n * bytes.\n */\n public writeUint16(value: number): this {\n this.ensureAvailable(2);\n this._data.setUint16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit signed integer and move pointer forward by 4\n * bytes.\n */\n public writeInt32(value: number): this {\n this.ensureAvailable(4);\n this._data.setInt32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n * bytes.\n */\n public writeUint32(value: number): this {\n this.ensureAvailable(4);\n this._data.setUint32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit floating number and move pointer forward by 4\n * bytes.\n */\n public writeFloat32(value: number): this {\n this.ensureAvailable(4);\n this._data.setFloat32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 64-bit floating number and move pointer forward by 8\n * bytes.\n */\n public writeFloat64(value: number): this {\n this.ensureAvailable(8);\n this._data.setFloat64(this.offset, value, this.littleEndian);\n this.offset += 8;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n * and move pointer forward by 1 byte.\n */\n public writeChar(str: string): this {\n return this.writeUint8(str.charCodeAt(0));\n }\n\n /**\n * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n * and move pointer forward by `str.length` bytes.\n */\n public writeChars(str: string): this {\n for (let i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i));\n }\n return this;\n }\n\n /**\n * UTF-8 encode and write `str` to the current pointer offset and move pointer\n * forward according to the encoded length.\n */\n public writeUtf8(str: string): this {\n const bytes = this.textEncoder.encode(str);\n return this.writeBytes(bytes);\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n */\n public toArray(): Uint8Array {\n return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n private _updateLastWrittenByte(): void {\n if (this.offset > this.lastWrittenByte) {\n this.lastWrittenByte = this.offset;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,mBAAmB,GAAG,IAAI,GAAG,CAAC;AAAC,IAWxBC,QAAQ;;EA4CnB,oBAAyF;IAAA,IAAtEC,IAAe,uEAAGF,mBAAmB;IAAA,IAAEG,OAAwB,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;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