@loaders.gl/netcdf 4.0.0-beta.3 → 4.0.0-beta.5

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.
Files changed (2) hide show
  1. package/dist/dist.dev.js +1 -236
  2. package/package.json +3 -3
package/dist/dist.dev.js CHANGED
@@ -34,31 +34,8 @@ var __exports__ = (() => {
34
34
  // src/iobuffer/iobuffer.ts
35
35
  var DEFAULT_BYTE_LENGTH = 1024 * 8;
36
36
  var IOBuffer = class {
37
- /**
38
- * Reference to the internal ArrayBuffer object.
39
- */
40
- /**
41
- * Byte length of the internal ArrayBuffer.
42
- */
43
- /**
44
- * Byte offset of the internal ArrayBuffer.
45
- */
46
- /**
47
- * Byte length of the internal ArrayBuffer.
48
- */
49
- /**
50
- * The current offset of the buffer's pointer.
51
- */
52
37
  textDecoder = new TextDecoder();
53
38
  textEncoder = new TextEncoder();
54
- /**
55
- * @param data - The data to construct the IOBuffer with.
56
- * If data is a number, it will be the new buffer's length<br>
57
- * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
58
- * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
59
- * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
60
- * @param options
61
- */
62
39
  constructor(data = DEFAULT_BYTE_LENGTH, options = {}) {
63
40
  let dataIsGiven = false;
64
41
  if (typeof data === "number") {
@@ -91,89 +68,43 @@ var __exports__ = (() => {
91
68
  this._mark = 0;
92
69
  this._marks = [];
93
70
  }
94
- /**
95
- * Checks if the memory allocated to the buffer is sufficient to store more
96
- * bytes after the offset.
97
- * @param byteLength - The needed memory in bytes.
98
- * @returns `true` if there is sufficient space and `false` otherwise.
99
- */
100
71
  available(byteLength = 1) {
101
72
  return this.offset + byteLength <= this.length;
102
73
  }
103
- /**
104
- * Check if little-endian mode is used for reading and writing multi-byte
105
- * values.
106
- * @returns `true` if little-endian mode is used, `false` otherwise.
107
- */
108
74
  isLittleEndian() {
109
75
  return this.littleEndian;
110
76
  }
111
- /**
112
- * Set little-endian mode for reading and writing multi-byte values.
113
- */
114
77
  setLittleEndian() {
115
78
  this.littleEndian = true;
116
79
  return this;
117
80
  }
118
- /**
119
- * Check if big-endian mode is used for reading and writing multi-byte values.
120
- * @returns `true` if big-endian mode is used, `false` otherwise.
121
- */
122
81
  isBigEndian() {
123
82
  return !this.littleEndian;
124
83
  }
125
- /**
126
- * Switches to big-endian mode for reading and writing multi-byte values.
127
- */
128
84
  setBigEndian() {
129
85
  this.littleEndian = false;
130
86
  return this;
131
87
  }
132
- /**
133
- * Move the pointer n bytes forward.
134
- * @param n - Number of bytes to skip.
135
- */
136
88
  skip(n = 1) {
137
89
  this.offset += n;
138
90
  return this;
139
91
  }
140
- /**
141
- * Move the pointer to the given offset.
142
- * @param offset
143
- */
144
92
  seek(offset) {
145
93
  this.offset = offset;
146
94
  return this;
147
95
  }
148
- /**
149
- * Store the current pointer offset.
150
- * @see {@link IOBuffer#reset}
151
- */
152
96
  mark() {
153
97
  this._mark = this.offset;
154
98
  return this;
155
99
  }
156
- /**
157
- * Move the pointer back to the last pointer offset set by mark.
158
- * @see {@link IOBuffer#mark}
159
- */
160
100
  reset() {
161
101
  this.offset = this._mark;
162
102
  return this;
163
103
  }
164
- /**
165
- * Push the current pointer offset to the mark stack.
166
- * @see {@link IOBuffer#popMark}
167
- */
168
104
  pushMark() {
169
105
  this._marks.push(this.offset);
170
106
  return this;
171
107
  }
172
- /**
173
- * Pop the last pointer offset from the mark stack, and set the current
174
- * pointer offset to the popped value.
175
- * @see {@link IOBuffer#pushMark}
176
- */
177
108
  popMark() {
178
109
  const offset = this._marks.pop();
179
110
  if (offset === void 0) {
@@ -182,20 +113,10 @@ var __exports__ = (() => {
182
113
  this.seek(offset);
183
114
  return this;
184
115
  }
185
- /**
186
- * Move the pointer offset back to 0.
187
- */
188
116
  rewind() {
189
117
  this.offset = 0;
190
118
  return this;
191
119
  }
192
- /**
193
- * Make sure the buffer has sufficient memory to write a given byteLength at
194
- * the current pointer offset.
195
- * If the buffer's memory is insufficient, this method will create a new
196
- * buffer (a copy) with a length that is twice (byteLength + current offset).
197
- * @param byteLength
198
- */
199
120
  ensureAvailable(byteLength = 1) {
200
121
  if (!this.available(byteLength)) {
201
122
  const lengthNeeded = this.offset + byteLength;
@@ -208,34 +129,18 @@ var __exports__ = (() => {
208
129
  }
209
130
  return this;
210
131
  }
211
- /**
212
- * Read a byte and return false if the byte's value is 0, or true otherwise.
213
- * Moves pointer forward by one byte.
214
- */
215
132
  readBoolean() {
216
133
  return this.readUint8() !== 0;
217
134
  }
218
- /**
219
- * Read a signed 8-bit integer and move pointer forward by 1 byte.
220
- */
221
135
  readInt8() {
222
136
  return this._data.getInt8(this.offset++);
223
137
  }
224
- /**
225
- * Read an unsigned 8-bit integer and move pointer forward by 1 byte.
226
- */
227
138
  readUint8() {
228
139
  return this._data.getUint8(this.offset++);
229
140
  }
230
- /**
231
- * Alias for {@link IOBuffer#readUint8}.
232
- */
233
141
  readByte() {
234
142
  return this.readUint8();
235
143
  }
236
- /**
237
- * Read `n` bytes and move pointer forward by `n` bytes.
238
- */
239
144
  readBytes(n = 1) {
240
145
  const bytes = new Uint8Array(n);
241
146
  for (let i = 0; i < n; i++) {
@@ -243,63 +148,39 @@ var __exports__ = (() => {
243
148
  }
244
149
  return bytes;
245
150
  }
246
- /**
247
- * Read a 16-bit signed integer and move pointer forward by 2 bytes.
248
- */
249
151
  readInt16() {
250
152
  const value = this._data.getInt16(this.offset, this.littleEndian);
251
153
  this.offset += 2;
252
154
  return value;
253
155
  }
254
- /**
255
- * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
256
- */
257
156
  readUint16() {
258
157
  const value = this._data.getUint16(this.offset, this.littleEndian);
259
158
  this.offset += 2;
260
159
  return value;
261
160
  }
262
- /**
263
- * Read a 32-bit signed integer and move pointer forward by 4 bytes.
264
- */
265
161
  readInt32() {
266
162
  const value = this._data.getInt32(this.offset, this.littleEndian);
267
163
  this.offset += 4;
268
164
  return value;
269
165
  }
270
- /**
271
- * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
272
- */
273
166
  readUint32() {
274
167
  const value = this._data.getUint32(this.offset, this.littleEndian);
275
168
  this.offset += 4;
276
169
  return value;
277
170
  }
278
- /**
279
- * Read a 32-bit floating number and move pointer forward by 4 bytes.
280
- */
281
171
  readFloat32() {
282
172
  const value = this._data.getFloat32(this.offset, this.littleEndian);
283
173
  this.offset += 4;
284
174
  return value;
285
175
  }
286
- /**
287
- * Read a 64-bit floating number and move pointer forward by 8 bytes.
288
- */
289
176
  readFloat64() {
290
177
  const value = this._data.getFloat64(this.offset, this.littleEndian);
291
178
  this.offset += 8;
292
179
  return value;
293
180
  }
294
- /**
295
- * Read a 1-byte ASCII character and move pointer forward by 1 byte.
296
- */
297
181
  readChar() {
298
182
  return String.fromCharCode(this.readInt8());
299
183
  }
300
- /**
301
- * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
302
- */
303
184
  readChars(n = 1) {
304
185
  let result = "";
305
186
  for (let i = 0; i < n; i++) {
@@ -307,50 +188,28 @@ var __exports__ = (() => {
307
188
  }
308
189
  return result;
309
190
  }
310
- /**
311
- * Read the next `n` bytes, return a UTF-8 decoded string and move pointer
312
- * forward by `n` bytes.
313
- */
314
191
  readUtf8(n = 1) {
315
192
  return this.textDecoder.decode(this.readBytes(n));
316
193
  }
317
- /**
318
- * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
319
- * forward by 1 byte.
320
- */
321
194
  writeBoolean(value) {
322
195
  this.writeUint8(value ? 255 : 0);
323
196
  return this;
324
197
  }
325
- /**
326
- * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
327
- */
328
198
  writeInt8(value) {
329
199
  this.ensureAvailable(1);
330
200
  this._data.setInt8(this.offset++, value);
331
201
  this._updateLastWrittenByte();
332
202
  return this;
333
203
  }
334
- /**
335
- * Write `value` as an 8-bit unsigned integer and move pointer forward by 1
336
- * byte.
337
- */
338
204
  writeUint8(value) {
339
205
  this.ensureAvailable(1);
340
206
  this._data.setUint8(this.offset++, value);
341
207
  this._updateLastWrittenByte();
342
208
  return this;
343
209
  }
344
- /**
345
- * An alias for {@link IOBuffer#writeUint8}.
346
- */
347
210
  writeByte(value) {
348
211
  return this.writeUint8(value);
349
212
  }
350
- /**
351
- * Write all elements of `bytes` as uint8 values and move pointer forward by
352
- * `bytes.length` bytes.
353
- */
354
213
  writeBytes(bytes) {
355
214
  this.ensureAvailable(bytes.length);
356
215
  for (let i = 0; i < bytes.length; i++) {
@@ -359,10 +218,6 @@ var __exports__ = (() => {
359
218
  this._updateLastWrittenByte();
360
219
  return this;
361
220
  }
362
- /**
363
- * Write `value` as a 16-bit signed integer and move pointer forward by 2
364
- * bytes.
365
- */
366
221
  writeInt16(value) {
367
222
  this.ensureAvailable(2);
368
223
  this._data.setInt16(this.offset, value, this.littleEndian);
@@ -370,10 +225,6 @@ var __exports__ = (() => {
370
225
  this._updateLastWrittenByte();
371
226
  return this;
372
227
  }
373
- /**
374
- * Write `value` as a 16-bit unsigned integer and move pointer forward by 2
375
- * bytes.
376
- */
377
228
  writeUint16(value) {
378
229
  this.ensureAvailable(2);
379
230
  this._data.setUint16(this.offset, value, this.littleEndian);
@@ -381,10 +232,6 @@ var __exports__ = (() => {
381
232
  this._updateLastWrittenByte();
382
233
  return this;
383
234
  }
384
- /**
385
- * Write `value` as a 32-bit signed integer and move pointer forward by 4
386
- * bytes.
387
- */
388
235
  writeInt32(value) {
389
236
  this.ensureAvailable(4);
390
237
  this._data.setInt32(this.offset, value, this.littleEndian);
@@ -392,10 +239,6 @@ var __exports__ = (() => {
392
239
  this._updateLastWrittenByte();
393
240
  return this;
394
241
  }
395
- /**
396
- * Write `value` as a 32-bit unsigned integer and move pointer forward by 4
397
- * bytes.
398
- */
399
242
  writeUint32(value) {
400
243
  this.ensureAvailable(4);
401
244
  this._data.setUint32(this.offset, value, this.littleEndian);
@@ -403,10 +246,6 @@ var __exports__ = (() => {
403
246
  this._updateLastWrittenByte();
404
247
  return this;
405
248
  }
406
- /**
407
- * Write `value` as a 32-bit floating number and move pointer forward by 4
408
- * bytes.
409
- */
410
249
  writeFloat32(value) {
411
250
  this.ensureAvailable(4);
412
251
  this._data.setFloat32(this.offset, value, this.littleEndian);
@@ -414,10 +253,6 @@ var __exports__ = (() => {
414
253
  this._updateLastWrittenByte();
415
254
  return this;
416
255
  }
417
- /**
418
- * Write `value` as a 64-bit floating number and move pointer forward by 8
419
- * bytes.
420
- */
421
256
  writeFloat64(value) {
422
257
  this.ensureAvailable(8);
423
258
  this._data.setFloat64(this.offset, value, this.littleEndian);
@@ -425,43 +260,22 @@ var __exports__ = (() => {
425
260
  this._updateLastWrittenByte();
426
261
  return this;
427
262
  }
428
- /**
429
- * Write the charCode of `str`'s first character as an 8-bit unsigned integer
430
- * and move pointer forward by 1 byte.
431
- */
432
263
  writeChar(str) {
433
264
  return this.writeUint8(str.charCodeAt(0));
434
265
  }
435
- /**
436
- * Write the charCodes of all `str`'s characters as 8-bit unsigned integers
437
- * and move pointer forward by `str.length` bytes.
438
- */
439
266
  writeChars(str) {
440
267
  for (let i = 0; i < str.length; i++) {
441
268
  this.writeUint8(str.charCodeAt(i));
442
269
  }
443
270
  return this;
444
271
  }
445
- /**
446
- * UTF-8 encode and write `str` to the current pointer offset and move pointer
447
- * forward according to the encoded length.
448
- */
449
272
  writeUtf8(str) {
450
273
  const bytes = this.textEncoder.encode(str);
451
274
  return this.writeBytes(bytes);
452
275
  }
453
- /**
454
- * Export a Uint8Array view of the internal buffer.
455
- * The view starts at the byte offset and its length
456
- * is calculated to stop at the last written byte or the original length.
457
- */
458
276
  toArray() {
459
277
  return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
460
278
  }
461
- /**
462
- * Update the last written byte offset
463
- * @private
464
- */
465
279
  _updateLastWrittenByte() {
466
280
  if (this.offset > this.lastWrittenByte) {
467
281
  this.lastWrittenByte = this.offset;
@@ -583,9 +397,7 @@ var __exports__ = (() => {
583
397
  recordDimension: {
584
398
  length: recordDimensionLength,
585
399
  id: dimList.recordId,
586
- // id of the unlimited dimension
587
400
  name: dimList.recordName,
588
- // name of the unlimited dimension
589
401
  recordStep: variableList.recordStep
590
402
  },
591
403
  dimensions: dimList.dimensions,
@@ -770,89 +582,46 @@ var __exports__ = (() => {
770
582
  this.header = readNetCDFHeader(buffer, version);
771
583
  this.buffer = buffer;
772
584
  }
773
- /**
774
- * @return {string} - Version for the NetCDF format
775
- */
776
585
  get version() {
777
586
  if (this.header.version === 1) {
778
587
  return "classic format";
779
588
  }
780
589
  return "64-bit offset format";
781
590
  }
782
- /**
783
- * Get metadata for the record dimension
784
- */
785
591
  get recordDimension() {
786
592
  return this.header.recordDimension;
787
593
  }
788
- /**
789
- * Get list of dimensions (each with `name` and `size`)
790
- */
791
594
  get dimensions() {
792
595
  return this.header.dimensions;
793
596
  }
794
- /**
795
- * Get list of global attributes with:
796
- * * `name`: String with the name of the attribute
797
- * * `type`: String with the type of the attribute
798
- * * `value`: A number or string with the value of the attribute
799
- */
800
597
  get attributes() {
801
598
  return this.header.attributes;
802
599
  }
803
- /**
804
- * Get list of variables
805
- */
806
600
  get variables() {
807
601
  return this.header.variables;
808
602
  }
809
- /**
810
- * Check if an attribute exists
811
- * @param attributeName - Name of the attribute to find
812
- * @return
813
- */
814
603
  attributeExists(attributeName) {
815
604
  const attribute = this.attributes.find((val) => val.name === attributeName);
816
605
  return attribute !== void 0;
817
606
  }
818
- /**
819
- * Returns the value of an attribute
820
- * @param attributeName
821
- * @return Value of the attributeName or null
822
- */
823
607
  getAttribute(attributeName) {
824
608
  const attribute = this.attributes.find((val) => val.name === attributeName);
825
609
  if (attribute)
826
610
  return attribute.value;
827
611
  return null;
828
612
  }
829
- /**
830
- * Check if a dataVariable exists
831
- * @param variableName - Name of the variable to find
832
- * @return
833
- */
834
613
  dataVariableExists(variableName) {
835
614
  const variable = this.header.variables.find(function(val) {
836
615
  return val.name === variableName;
837
616
  });
838
617
  return variable !== void 0;
839
618
  }
840
- /**
841
- * Returns the value of a variable as a string
842
- * @param variableName
843
- * @return Value of the variable as a string or null
844
- */
845
619
  getDataVariableAsString(variableName) {
846
620
  const variable = this.getDataVariable(variableName);
847
621
  if (variable)
848
622
  return variable.join("");
849
623
  return null;
850
624
  }
851
- /**
852
- * Retrieves the data for a given variable
853
- * @param variableName - Name of the variable to search or variable object
854
- * @return List with the variable values
855
- */
856
625
  getDataVariable(variableName) {
857
626
  let variable;
858
627
  if (typeof variableName === "string") {
@@ -907,11 +676,7 @@ var __exports__ = (() => {
907
676
  module: "mvt",
908
677
  version: VERSION,
909
678
  extensions: ["cdf", "nc"],
910
- mimeTypes: [
911
- "application/netcdf",
912
- "application/x-netcdf"
913
- // 'application/octet-stream'
914
- ],
679
+ mimeTypes: ["application/netcdf", "application/x-netcdf"],
915
680
  category: "image",
916
681
  options: {
917
682
  netcdf: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/netcdf",
3
3
  "description": "Loader for NetCDF",
4
- "version": "4.0.0-beta.3",
4
+ "version": "4.0.0-beta.5",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -38,7 +38,7 @@
38
38
  "build-bundle": "ocular-bundle ./src/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@loaders.gl/loader-utils": "4.0.0-beta.3"
41
+ "@loaders.gl/loader-utils": "4.0.0-beta.5"
42
42
  },
43
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
43
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
44
44
  }