@loaders.gl/netcdf 3.4.0-alpha.2 → 3.4.0-alpha.3

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.
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","names":["_netcdfReader","require","_netcdfLoader"],"sources":["../../src/index.ts"],"sourcesContent":["export {NetCDFReader} from './netcdfjs/netcdf-reader';\n\nexport {NetCDFLoader} from './netcdf-loader';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA"}
@@ -10,7 +10,6 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var DEFAULT_BYTE_LENGTH = 1024 * 8;
12
12
  var IOBuffer = function () {
13
-
14
13
  function IOBuffer() {
15
14
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BYTE_LENGTH;
16
15
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -58,90 +57,68 @@ var IOBuffer = function () {
58
57
  this._mark = 0;
59
58
  this._marks = [];
60
59
  }
61
-
62
60
  (0, _createClass2.default)(IOBuffer, [{
63
61
  key: "available",
64
- value:
65
- function available() {
62
+ value: function available() {
66
63
  var byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
67
64
  return this.offset + byteLength <= this.length;
68
65
  }
69
-
70
66
  }, {
71
67
  key: "isLittleEndian",
72
- value:
73
- function isLittleEndian() {
68
+ value: function isLittleEndian() {
74
69
  return this.littleEndian;
75
70
  }
76
-
77
71
  }, {
78
72
  key: "setLittleEndian",
79
- value:
80
- function setLittleEndian() {
73
+ value: function setLittleEndian() {
81
74
  this.littleEndian = true;
82
75
  return this;
83
76
  }
84
-
85
77
  }, {
86
78
  key: "isBigEndian",
87
- value:
88
- function isBigEndian() {
79
+ value: function isBigEndian() {
89
80
  return !this.littleEndian;
90
81
  }
91
-
92
82
  }, {
93
83
  key: "setBigEndian",
94
- value:
95
- function setBigEndian() {
84
+ value: function setBigEndian() {
96
85
  this.littleEndian = false;
97
86
  return this;
98
87
  }
99
-
100
88
  }, {
101
89
  key: "skip",
102
- value:
103
- function skip() {
90
+ value: function skip() {
104
91
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
105
92
  this.offset += n;
106
93
  return this;
107
94
  }
108
-
109
95
  }, {
110
96
  key: "seek",
111
- value:
112
- function seek(offset) {
97
+ value: function seek(offset) {
113
98
  this.offset = offset;
114
99
  return this;
115
100
  }
116
-
117
101
  }, {
118
102
  key: "mark",
119
- value:
120
- function mark() {
103
+ value: function mark() {
121
104
  this._mark = this.offset;
122
105
  return this;
123
106
  }
124
-
125
107
  }, {
126
108
  key: "reset",
127
- value:
128
- function reset() {
109
+ value: function reset() {
129
110
  this.offset = this._mark;
130
111
  return this;
131
112
  }
132
-
133
113
  }, {
134
114
  key: "pushMark",
135
- value:
136
- function pushMark() {
115
+ value: function pushMark() {
137
116
  this._marks.push(this.offset);
138
117
  return this;
139
118
  }
140
-
141
119
  }, {
142
120
  key: "popMark",
143
- value:
144
- function popMark() {
121
+ value: function popMark() {
145
122
  var offset = this._marks.pop();
146
123
  if (offset === undefined) {
147
124
  throw new Error('Mark stack empty');
@@ -149,19 +126,15 @@ var IOBuffer = function () {
149
126
  this.seek(offset);
150
127
  return this;
151
128
  }
152
-
153
129
  }, {
154
130
  key: "rewind",
155
- value:
156
- function rewind() {
131
+ value: function rewind() {
157
132
  this.offset = 0;
158
133
  return this;
159
134
  }
160
-
161
135
  }, {
162
136
  key: "ensureAvailable",
163
- value:
164
- function ensureAvailable() {
137
+ value: function ensureAvailable() {
165
138
  var byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
166
139
  if (!this.available(byteLength)) {
167
140
  var lengthNeeded = this.offset + byteLength;
@@ -174,39 +147,29 @@ var IOBuffer = function () {
174
147
  }
175
148
  return this;
176
149
  }
177
-
178
150
  }, {
179
151
  key: "readBoolean",
180
- value:
181
- function readBoolean() {
152
+ value: function readBoolean() {
182
153
  return this.readUint8() !== 0;
183
154
  }
184
-
185
155
  }, {
186
156
  key: "readInt8",
187
- value:
188
- function readInt8() {
157
+ value: function readInt8() {
189
158
  return this._data.getInt8(this.offset++);
190
159
  }
191
-
192
160
  }, {
193
161
  key: "readUint8",
194
- value:
195
- function readUint8() {
162
+ value: function readUint8() {
196
163
  return this._data.getUint8(this.offset++);
197
164
  }
198
-
199
165
  }, {
200
166
  key: "readByte",
201
- value:
202
- function readByte() {
167
+ value: function readByte() {
203
168
  return this.readUint8();
204
169
  }
205
-
206
170
  }, {
207
171
  key: "readBytes",
208
- value:
209
- function readBytes() {
172
+ value: function readBytes() {
210
173
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
211
174
  var bytes = new Uint8Array(n);
212
175
  for (var i = 0; i < n; i++) {
@@ -214,72 +177,56 @@ var IOBuffer = function () {
214
177
  }
215
178
  return bytes;
216
179
  }
217
-
218
180
  }, {
219
181
  key: "readInt16",
220
- value:
221
- function readInt16() {
182
+ value: function readInt16() {
222
183
  var value = this._data.getInt16(this.offset, this.littleEndian);
223
184
  this.offset += 2;
224
185
  return value;
225
186
  }
226
-
227
187
  }, {
228
188
  key: "readUint16",
229
- value:
230
- function readUint16() {
189
+ value: function readUint16() {
231
190
  var value = this._data.getUint16(this.offset, this.littleEndian);
232
191
  this.offset += 2;
233
192
  return value;
234
193
  }
235
-
236
194
  }, {
237
195
  key: "readInt32",
238
- value:
239
- function readInt32() {
196
+ value: function readInt32() {
240
197
  var value = this._data.getInt32(this.offset, this.littleEndian);
241
198
  this.offset += 4;
242
199
  return value;
243
200
  }
244
-
245
201
  }, {
246
202
  key: "readUint32",
247
- value:
248
- function readUint32() {
203
+ value: function readUint32() {
249
204
  var value = this._data.getUint32(this.offset, this.littleEndian);
250
205
  this.offset += 4;
251
206
  return value;
252
207
  }
253
-
254
208
  }, {
255
209
  key: "readFloat32",
256
- value:
257
- function readFloat32() {
210
+ value: function readFloat32() {
258
211
  var value = this._data.getFloat32(this.offset, this.littleEndian);
259
212
  this.offset += 4;
260
213
  return value;
261
214
  }
262
-
263
215
  }, {
264
216
  key: "readFloat64",
265
- value:
266
- function readFloat64() {
217
+ value: function readFloat64() {
267
218
  var value = this._data.getFloat64(this.offset, this.littleEndian);
268
219
  this.offset += 8;
269
220
  return value;
270
221
  }
271
-
272
222
  }, {
273
223
  key: "readChar",
274
- value:
275
- function readChar() {
224
+ value: function readChar() {
276
225
  return String.fromCharCode(this.readInt8());
277
226
  }
278
-
279
227
  }, {
280
228
  key: "readChars",
281
- value:
282
- function readChars() {
229
+ value: function readChars() {
283
230
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
284
231
  var result = '';
285
232
  for (var i = 0; i < n; i++) {
@@ -287,54 +234,42 @@ var IOBuffer = function () {
287
234
  }
288
235
  return result;
289
236
  }
290
-
291
237
  }, {
292
238
  key: "readUtf8",
293
- value:
294
- function readUtf8() {
239
+ value: function readUtf8() {
295
240
  var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
296
241
  return this.textDecoder.decode(this.readBytes(n));
297
242
  }
298
-
299
243
  }, {
300
244
  key: "writeBoolean",
301
- value:
302
- function writeBoolean(value) {
245
+ value: function writeBoolean(value) {
303
246
  this.writeUint8(value ? 0xff : 0x00);
304
247
  return this;
305
248
  }
306
-
307
249
  }, {
308
250
  key: "writeInt8",
309
- value:
310
- function writeInt8(value) {
251
+ value: function writeInt8(value) {
311
252
  this.ensureAvailable(1);
312
253
  this._data.setInt8(this.offset++, value);
313
254
  this._updateLastWrittenByte();
314
255
  return this;
315
256
  }
316
-
317
257
  }, {
318
258
  key: "writeUint8",
319
- value:
320
- function writeUint8(value) {
259
+ value: function writeUint8(value) {
321
260
  this.ensureAvailable(1);
322
261
  this._data.setUint8(this.offset++, value);
323
262
  this._updateLastWrittenByte();
324
263
  return this;
325
264
  }
326
-
327
265
  }, {
328
266
  key: "writeByte",
329
- value:
330
- function writeByte(value) {
267
+ value: function writeByte(value) {
331
268
  return this.writeUint8(value);
332
269
  }
333
-
334
270
  }, {
335
271
  key: "writeBytes",
336
- value:
337
- function writeBytes(bytes) {
272
+ value: function writeBytes(bytes) {
338
273
  this.ensureAvailable(bytes.length);
339
274
  for (var i = 0; i < bytes.length; i++) {
340
275
  this._data.setUint8(this.offset++, bytes[i]);
@@ -342,109 +277,87 @@ var IOBuffer = function () {
342
277
  this._updateLastWrittenByte();
343
278
  return this;
344
279
  }
345
-
346
280
  }, {
347
281
  key: "writeInt16",
348
- value:
349
- function writeInt16(value) {
282
+ value: function writeInt16(value) {
350
283
  this.ensureAvailable(2);
351
284
  this._data.setInt16(this.offset, value, this.littleEndian);
352
285
  this.offset += 2;
353
286
  this._updateLastWrittenByte();
354
287
  return this;
355
288
  }
356
-
357
289
  }, {
358
290
  key: "writeUint16",
359
- value:
360
- function writeUint16(value) {
291
+ value: function writeUint16(value) {
361
292
  this.ensureAvailable(2);
362
293
  this._data.setUint16(this.offset, value, this.littleEndian);
363
294
  this.offset += 2;
364
295
  this._updateLastWrittenByte();
365
296
  return this;
366
297
  }
367
-
368
298
  }, {
369
299
  key: "writeInt32",
370
- value:
371
- function writeInt32(value) {
300
+ value: function writeInt32(value) {
372
301
  this.ensureAvailable(4);
373
302
  this._data.setInt32(this.offset, value, this.littleEndian);
374
303
  this.offset += 4;
375
304
  this._updateLastWrittenByte();
376
305
  return this;
377
306
  }
378
-
379
307
  }, {
380
308
  key: "writeUint32",
381
- value:
382
- function writeUint32(value) {
309
+ value: function writeUint32(value) {
383
310
  this.ensureAvailable(4);
384
311
  this._data.setUint32(this.offset, value, this.littleEndian);
385
312
  this.offset += 4;
386
313
  this._updateLastWrittenByte();
387
314
  return this;
388
315
  }
389
-
390
316
  }, {
391
317
  key: "writeFloat32",
392
- value:
393
- function writeFloat32(value) {
318
+ value: function writeFloat32(value) {
394
319
  this.ensureAvailable(4);
395
320
  this._data.setFloat32(this.offset, value, this.littleEndian);
396
321
  this.offset += 4;
397
322
  this._updateLastWrittenByte();
398
323
  return this;
399
324
  }
400
-
401
325
  }, {
402
326
  key: "writeFloat64",
403
- value:
404
- function writeFloat64(value) {
327
+ value: function writeFloat64(value) {
405
328
  this.ensureAvailable(8);
406
329
  this._data.setFloat64(this.offset, value, this.littleEndian);
407
330
  this.offset += 8;
408
331
  this._updateLastWrittenByte();
409
332
  return this;
410
333
  }
411
-
412
334
  }, {
413
335
  key: "writeChar",
414
- value:
415
- function writeChar(str) {
336
+ value: function writeChar(str) {
416
337
  return this.writeUint8(str.charCodeAt(0));
417
338
  }
418
-
419
339
  }, {
420
340
  key: "writeChars",
421
- value:
422
- function writeChars(str) {
341
+ value: function writeChars(str) {
423
342
  for (var i = 0; i < str.length; i++) {
424
343
  this.writeUint8(str.charCodeAt(i));
425
344
  }
426
345
  return this;
427
346
  }
428
-
429
347
  }, {
430
348
  key: "writeUtf8",
431
- value:
432
- function writeUtf8(str) {
349
+ value: function writeUtf8(str) {
433
350
  var bytes = this.textEncoder.encode(str);
434
351
  return this.writeBytes(bytes);
435
352
  }
436
-
437
353
  }, {
438
354
  key: "toArray",
439
- value:
440
- function toArray() {
355
+ value: function toArray() {
441
356
  return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
442
357
  }
443
-
444
358
  }, {
445
359
  key: "_updateLastWrittenByte",
446
- value:
447
- function _updateLastWrittenByte() {
360
+ value: function _updateLastWrittenByte() {
448
361
  if (this.offset > this.lastWrittenByte) {
449
362
  this.lastWrittenByte = this.offset;
450
363
  }
@@ -1 +1 @@
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;IAAA;IAAA;IAAA;IAAA,mDAXjE,IAAI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AI,CAAC+C,sBAAsB,EAAE;MAC7B,OAAO,IAAI;IACb;;EAAC;IAAA;IAAA;IAMD,mBAAiBQ,GAAW,EAAQ;MAClC,OAAO,IAAI,CAACX,UAAU,CAACW,GAAG,CAACC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C;;EAAC;IAAA;IAAA;IAMD,oBAAkBD,GAAW,EAAQ;MACnC,KAAK,IAAI5B,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG4B,GAAG,CAAClD,MAAM,EAAEsB,CAAC,EAAE,EAAE;QACnC,IAAI,CAACiB,UAAU,CAACW,GAAG,CAACC,UAAU,CAAC7B,CAAC,CAAC,CAAC;MACpC;MACA,OAAO,IAAI;IACb;;EAAC;IAAA;IAAA;IAMD,mBAAiB4B,GAAW,EAAQ;MAClC,IAAM7B,KAAK,GAAG,IAAI,CAAC+B,WAAW,CAACC,MAAM,CAACH,GAAG,CAAC;MAC1C,OAAO,IAAI,CAACI,UAAU,CAACjC,KAAK,CAAC;IAC/B;;EAAC;IAAA;IAAA;IAOD,mBAA6B;MAC3B,OAAO,IAAIL,UAAU,CAAC,IAAI,CAAClB,MAAM,EAAE,IAAI,CAACC,UAAU,EAAE,IAAI,CAACN,eAAe,CAAC;IAC3E;;EAAC;IAAA;IAAA;IAMD,kCAAuC;MACrC,IAAI,IAAI,CAACE,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;QACtC,IAAI,CAACA,eAAe,GAAG,IAAI,CAACE,MAAM;MACpC;IACF;EAAC;EAAA;AAAA;AAAA"}
1
+ {"version":3,"file":"iobuffer.js","names":["DEFAULT_BYTE_LENGTH","IOBuffer","data","arguments","length","undefined","options","_classCallCheck2","default","_defineProperty2","TextDecoder","TextEncoder","dataIsGiven","ArrayBuffer","lastWrittenByte","byteLength","offset","dvOffset","isView","buffer","byteOffset","littleEndian","_data","DataView","_mark","_marks","_createClass2","key","value","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","n","seek","mark","reset","pushMark","push","popMark","pop","Error","rewind","ensureAvailable","lengthNeeded","newLength","newArray","Uint8Array","set","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","i","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","String","fromCharCode","readChars","result","readUtf8","textDecoder","decode","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","str","charCodeAt","writeChars","writeUtf8","textEncoder","encode","toArray","exports"],"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,SAAAA,SAAA,EAAyF;IAAA,IAAtEC,IAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGH,mBAAmB;IAAA,IAAEM,OAAwB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,G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,IAAI,CAAC+C,WAAW,CAACC,MAAM,CAACL,GAAG,CAAC;MAC1C,OAAO,IAAI,CAACd,UAAU,CAAC7B,KAAK,CAAC;IAC/B;EAAC;IAAA/B,GAAA;IAAAC,KAAA,EAOD,SAAA+E,QAAA,EAA6B;MAC3B,OAAO,IAAI1D,UAAU,CAAC,IAAI,CAAC9B,MAAM,EAAE,IAAI,CAACC,UAAU,EAAE,IAAI,CAACN,eAAe,CAAC;IAC3E;EAAC;IAAAa,GAAA;IAAAC,KAAA,EAMD,SAAAwD,uBAAA,EAAuC;MACrC,IAAI,IAAI,CAACpE,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;QACtC,IAAI,CAACA,eAAe,GAAG,IAAI,CAACE,MAAM;MACpC;IACF;EAAC;EAAA,OAAAf,QAAA;AAAA;AAAA2G,OAAA,CAAA3G,QAAA,GAAAA,QAAA"}
@@ -11,19 +11,17 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
  var _netcdfReader = require("./netcdfjs/netcdf-reader");
12
12
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
- var VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest';
17
+ var VERSION = typeof "3.4.0-alpha.3" !== 'undefined' ? "3.4.0-alpha.3" : 'latest';
18
18
  var NetCDFWorkerLoader = {
19
19
  name: 'NetCDF',
20
20
  id: 'mvt',
21
21
  module: 'mvt',
22
22
  version: VERSION,
23
23
  extensions: ['cdf', 'nc'],
24
- mimeTypes: ['application/netcdf', 'application/x-netcdf'
25
- ],
26
-
24
+ mimeTypes: ['application/netcdf', 'application/x-netcdf'],
27
25
  category: 'image',
28
26
  options: {
29
27
  netcdf: {
@@ -31,20 +29,17 @@ var NetCDFWorkerLoader = {
31
29
  }
32
30
  }
33
31
  };
34
-
35
32
  exports.NetCDFWorkerLoader = NetCDFWorkerLoader;
36
33
  var NetCDFLoader = _objectSpread(_objectSpread({}, NetCDFWorkerLoader), {}, {
37
34
  parse: function () {
38
35
  var _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
39
36
  return _regenerator.default.wrap(function _callee$(_context) {
40
- while (1) {
41
- switch (_context.prev = _context.next) {
42
- case 0:
43
- return _context.abrupt("return", parseNetCDF(arrayBuffer, options));
44
- case 1:
45
- case "end":
46
- return _context.stop();
47
- }
37
+ while (1) switch (_context.prev = _context.next) {
38
+ case 0:
39
+ return _context.abrupt("return", parseNetCDF(arrayBuffer, options));
40
+ case 1:
41
+ case "end":
42
+ return _context.stop();
48
43
  }
49
44
  }, _callee);
50
45
  }));
@@ -79,7 +74,6 @@ function parseNetCDF(arrayBuffer, options) {
79
74
  data: variables
80
75
  };
81
76
  }
82
-
83
77
  var _typecheckNetCDFWorkerLoader = NetCDFWorkerLoader;
84
78
  exports._typecheckNetCDFWorkerLoader = _typecheckNetCDFWorkerLoader;
85
79
  var _typecheckNetCDFLoader = NetCDFLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"netcdf-loader.js","names":["VERSION","NetCDFWorkerLoader","name","id","module","version","extensions","mimeTypes","category","options","netcdf","loadVariables","NetCDFLoader","parse","arrayBuffer","parseNetCDF","binary","reader","NetCDFReader","variables","loadData","variable","getDataVariable","loaderData","header","data","_typecheckNetCDFWorkerLoader","_typecheckNetCDFLoader"],"sources":["../../src/netcdf-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {NetCDFHeader} from './netcdfjs/netcdf-types';\nimport {NetCDFReader} from './netcdfjs/netcdf-reader';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type NetCDF = {\n loaderData: NetCDFHeader;\n data: {[variableName: string]: any[][]};\n};\n\nexport type NetCDFLoaderOptions = LoaderOptions & {\n netcdf?: {\n loadData?: boolean;\n };\n};\n\n/**\n * Worker loader for NETCDF\n */\nexport const NetCDFWorkerLoader = {\n name: 'NetCDF',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n extensions: ['cdf', 'nc'],\n mimeTypes: [\n 'application/netcdf',\n 'application/x-netcdf'\n // 'application/octet-stream'\n ],\n category: 'image',\n options: {\n netcdf: {\n loadVariables: false\n }\n }\n};\n\n/**\n * Loader for the NetCDF format\n */\nexport const NetCDFLoader = {\n ...NetCDFWorkerLoader,\n parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options),\n binary: true\n};\n\nfunction parseNetCDF(arrayBuffer: ArrayBuffer, options?: NetCDFLoaderOptions): NetCDF {\n const reader = new NetCDFReader(arrayBuffer);\n const variables: {[variableName: string]: any[][]} = {};\n if (options?.netcdf?.loadData) {\n for (const variable of reader.variables) {\n variables[variable.name] = reader.getDataVariable(variable);\n }\n }\n return {\n loaderData: reader.header,\n data: variables\n };\n}\n\n// Type tests\nexport const _typecheckNetCDFWorkerLoader: Loader = NetCDFWorkerLoader;\nexport const _typecheckNetCDFLoader: LoaderWithParser = NetCDFLoader;\n"],"mappings":";;;;;;;;;;AAEA;AAAsD;AAAA;AAAA;AAAA;AAAA;AAItD,IAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAgBpE,IAAMC,kBAAkB,GAAG;EAChCC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;EACzBC,SAAS,EAAE,CACT,oBAAoB,EACpB;EAAsB,CAEvB;;EACDC,QAAQ,EAAE,OAAO;EACjBC,OAAO,EAAE;IACPC,MAAM,EAAE;MACNC,aAAa,EAAE;IACjB;EACF;AACF,CAAC;;AAAC;AAKK,IAAMC,YAAY,mCACpBX,kBAAkB;EACrBY,KAAK;IAAA,uEAAE,iBAAOC,WAAW,EAAEL,OAAO;MAAA;QAAA;UAAA;YAAA;cAAA,iCAAKM,WAAW,CAACD,WAAW,EAAEL,OAAO,CAAC;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA;IAAA;IAAA;MAAA;IAAA;IAAA;EAAA;EACxEO,MAAM,EAAE;AAAI,EACb;AAAC;AAEF,SAASD,WAAW,CAACD,WAAwB,EAAEL,OAA6B,EAAU;EAAA;EACpF,IAAMQ,MAAM,GAAG,IAAIC,0BAAY,CAACJ,WAAW,CAAC;EAC5C,IAAMK,SAA4C,GAAG,CAAC,CAAC;EACvD,IAAIV,OAAO,aAAPA,OAAO,kCAAPA,OAAO,CAAEC,MAAM,4CAAf,gBAAiBU,QAAQ,EAAE;IAAA,2CACNH,MAAM,CAACE,SAAS;MAAA;IAAA;MAAvC,oDAAyC;QAAA,IAA9BE,QAAQ;QACjBF,SAAS,CAACE,QAAQ,CAACnB,IAAI,CAAC,GAAGe,MAAM,CAACK,eAAe,CAACD,QAAQ,CAAC;MAC7D;IAAC;MAAA;IAAA;MAAA;IAAA;EACH;EACA,OAAO;IACLE,UAAU,EAAEN,MAAM,CAACO,MAAM;IACzBC,IAAI,EAAEN;EACR,CAAC;AACH;;AAGO,IAAMO,4BAAoC,GAAGzB,kBAAkB;AAAC;AAChE,IAAM0B,sBAAwC,GAAGf,YAAY;AAAC"}
1
+ {"version":3,"file":"netcdf-loader.js","names":["_netcdfReader","require","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","arguments","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","VERSION","NetCDFWorkerLoader","id","module","version","extensions","mimeTypes","category","options","netcdf","loadVariables","exports","NetCDFLoader","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","abrupt","parseNetCDF","stop","_x","_x2","binary","_options$netcdf","reader","NetCDFReader","variables","loadData","_iterator","_step","variable","getDataVariable","loaderData","header","data","_typecheckNetCDFWorkerLoader","_typecheckNetCDFLoader"],"sources":["../../src/netcdf-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {NetCDFHeader} from './netcdfjs/netcdf-types';\nimport {NetCDFReader} from './netcdfjs/netcdf-reader';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type NetCDF = {\n loaderData: NetCDFHeader;\n data: {[variableName: string]: any[][]};\n};\n\nexport type NetCDFLoaderOptions = LoaderOptions & {\n netcdf?: {\n loadData?: boolean;\n };\n};\n\n/**\n * Worker loader for NETCDF\n */\nexport const NetCDFWorkerLoader = {\n name: 'NetCDF',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n extensions: ['cdf', 'nc'],\n mimeTypes: [\n 'application/netcdf',\n 'application/x-netcdf'\n // 'application/octet-stream'\n ],\n category: 'image',\n options: {\n netcdf: {\n loadVariables: false\n }\n }\n};\n\n/**\n * Loader for the NetCDF format\n */\nexport const NetCDFLoader = {\n ...NetCDFWorkerLoader,\n parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options),\n binary: true\n};\n\nfunction parseNetCDF(arrayBuffer: ArrayBuffer, options?: NetCDFLoaderOptions): NetCDF {\n const reader = new NetCDFReader(arrayBuffer);\n const variables: {[variableName: string]: any[][]} = {};\n if (options?.netcdf?.loadData) {\n for (const variable of reader.variables) {\n variables[variable.name] = reader.getDataVariable(variable);\n }\n }\n return {\n loaderData: reader.header,\n data: variables\n };\n}\n\n// Type tests\nexport const _typecheckNetCDFWorkerLoader: Loader = NetCDFWorkerLoader;\nexport const _typecheckNetCDFLoader: LoaderWithParser = NetCDFLoader;\n"],"mappings":";;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAAsD,SAAAC,2BAAAC,CAAA,EAAAC,cAAA,QAAAC,EAAA,UAAAC,MAAA,oBAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,EAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,EAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,cAAA,IAAAD,CAAA,WAAAA,CAAA,CAAAQ,MAAA,qBAAAN,EAAA,EAAAF,CAAA,GAAAE,EAAA,MAAAO,CAAA,UAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,QAAAH,CAAA,IAAAT,CAAA,CAAAQ,MAAA,WAAAK,IAAA,mBAAAA,IAAA,SAAAC,KAAA,EAAAd,CAAA,CAAAS,CAAA,UAAAM,CAAA,WAAAA,EAAAC,EAAA,UAAAA,EAAA,KAAAC,CAAA,EAAAP,CAAA,gBAAAQ,SAAA,iJAAAC,gBAAA,SAAAC,MAAA,UAAAC,GAAA,WAAAV,CAAA,WAAAA,EAAA,IAAAT,EAAA,GAAAA,EAAA,CAAAoB,IAAA,CAAAtB,CAAA,MAAAY,CAAA,WAAAA,EAAA,QAAAW,IAAA,GAAArB,EAAA,CAAAsB,IAAA,IAAAL,gBAAA,GAAAI,IAAA,CAAAV,IAAA,SAAAU,IAAA,KAAAR,CAAA,WAAAA,EAAAU,GAAA,IAAAL,MAAA,SAAAC,GAAA,GAAAI,G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