@nirs4all/formats-wasm 0.2.13 → 0.2.14

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.
@@ -21,7 +21,7 @@ export function features(): any;
21
21
  * Single-file HDF5 / NetCDF payloads decode directly through this entry
22
22
  * point now that `fmt-hdf5` is on.
23
23
  */
24
- export function openBytes(filename: string, bytes: Uint8Array): any;
24
+ export function openBytes(filename: string, bytes: Uint8Array | number[]): any;
25
25
 
26
26
  /**
27
27
  * Decode a file by name + bytes plus a map of sidecar names → byte
@@ -30,7 +30,7 @@ export function openBytes(filename: string, bytes: Uint8Array): any;
30
30
  * AVIRIS/ERDAS LAN and the HDF5-backed sidecar formats (FGI XML+HDF5,
31
31
  * NetCDF MFRSR with its QC YAML) now that `fmt-hdf5` is on.
32
32
  */
33
- export function openWithSidecars(filename: string, bytes: Uint8Array, sidecars: any): any;
33
+ export function openWithSidecars(filename: string, bytes: Uint8Array | number[], sidecars: any): any;
34
34
 
35
35
  /**
36
36
  * Probe a file by name + bytes. Returns the ordered candidate readers.
@@ -40,7 +40,7 @@ export function openWithSidecars(filename: string, bytes: Uint8Array, sidecars:
40
40
  * inspected; pass the entire buffer or just the head — the implementation is
41
41
  * the same.
42
42
  */
43
- export function probeBytes(filename: string, bytes: Uint8Array): any;
43
+ export function probeBytes(filename: string, bytes: Uint8Array | number[]): any;
44
44
 
45
45
  /**
46
46
  * Readers compiled into this WASM bundle.
@@ -58,7 +58,7 @@ export function recommended_chunk_size_mb(): number;
58
58
  * payload. The rules live inside each format module; this binding only
59
59
  * serializes them for browser UIs.
60
60
  */
61
- export function sidecarRequirements(filename: string, bytes: Uint8Array): any;
61
+ export function sidecarRequirements(filename: string, bytes: Uint8Array | number[]): any;
62
62
 
63
63
  /**
64
64
  * Crate version exposed to JS.
@@ -31,14 +31,21 @@ exports.features = features;
31
31
  * Single-file HDF5 / NetCDF payloads decode directly through this entry
32
32
  * point now that `fmt-hdf5` is on.
33
33
  * @param {string} filename
34
- * @param {Uint8Array} bytes
34
+ * @param {Uint8Array | number[]} bytes
35
35
  * @returns {any}
36
36
  */
37
37
  function openBytes(filename, bytes) {
38
- const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
- const len0 = WASM_VECTOR_LEN;
40
- const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
41
- const len1 = WASM_VECTOR_LEN;
38
+ let ptr0, len0, ptr1, len1;
39
+ try {
40
+ ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ len0 = WASM_VECTOR_LEN;
42
+ ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
43
+ len1 = WASM_VECTOR_LEN;
44
+ } catch (e) {
45
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
46
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
47
+ throw e;
48
+ }
42
49
  const ret = wasm.openBytes(ptr0, len0, ptr1, len1);
43
50
  if (ret[2]) {
44
51
  throw takeFromExternrefTable0(ret[1]);
@@ -54,15 +61,22 @@ exports.openBytes = openBytes;
54
61
  * AVIRIS/ERDAS LAN and the HDF5-backed sidecar formats (FGI XML+HDF5,
55
62
  * NetCDF MFRSR with its QC YAML) now that `fmt-hdf5` is on.
56
63
  * @param {string} filename
57
- * @param {Uint8Array} bytes
64
+ * @param {Uint8Array | number[]} bytes
58
65
  * @param {any} sidecars
59
66
  * @returns {any}
60
67
  */
61
68
  function openWithSidecars(filename, bytes, sidecars) {
62
- const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
63
- const len0 = WASM_VECTOR_LEN;
64
- const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
65
- const len1 = WASM_VECTOR_LEN;
69
+ let ptr0, len0, ptr1, len1;
70
+ try {
71
+ ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ len0 = WASM_VECTOR_LEN;
73
+ ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
74
+ len1 = WASM_VECTOR_LEN;
75
+ } catch (e) {
76
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
77
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
78
+ throw e;
79
+ }
66
80
  const ret = wasm.openWithSidecars(ptr0, len0, ptr1, len1, sidecars);
67
81
  if (ret[2]) {
68
82
  throw takeFromExternrefTable0(ret[1]);
@@ -79,14 +93,21 @@ exports.openWithSidecars = openWithSidecars;
79
93
  * inspected; pass the entire buffer or just the head — the implementation is
80
94
  * the same.
81
95
  * @param {string} filename
82
- * @param {Uint8Array} bytes
96
+ * @param {Uint8Array | number[]} bytes
83
97
  * @returns {any}
84
98
  */
85
99
  function probeBytes(filename, bytes) {
86
- const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
- const len0 = WASM_VECTOR_LEN;
88
- const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
89
- const len1 = WASM_VECTOR_LEN;
100
+ let ptr0, len0, ptr1, len1;
101
+ try {
102
+ ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ len0 = WASM_VECTOR_LEN;
104
+ ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
105
+ len1 = WASM_VECTOR_LEN;
106
+ } catch (e) {
107
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
108
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
109
+ throw e;
110
+ }
90
111
  const ret = wasm.probeBytes(ptr0, len0, ptr1, len1);
91
112
  if (ret[2]) {
92
113
  throw takeFromExternrefTable0(ret[1]);
@@ -126,14 +147,21 @@ exports.recommended_chunk_size_mb = recommended_chunk_size_mb;
126
147
  * payload. The rules live inside each format module; this binding only
127
148
  * serializes them for browser UIs.
128
149
  * @param {string} filename
129
- * @param {Uint8Array} bytes
150
+ * @param {Uint8Array | number[]} bytes
130
151
  * @returns {any}
131
152
  */
132
153
  function sidecarRequirements(filename, bytes) {
133
- const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
134
- const len0 = WASM_VECTOR_LEN;
135
- const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
136
- const len1 = WASM_VECTOR_LEN;
154
+ let ptr0, len0, ptr1, len1;
155
+ try {
156
+ ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ len0 = WASM_VECTOR_LEN;
158
+ ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
159
+ len1 = WASM_VECTOR_LEN;
160
+ } catch (e) {
161
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
162
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
163
+ throw e;
164
+ }
137
165
  const ret = wasm.sidecarRequirements(ptr0, len0, ptr1, len1);
138
166
  if (ret[2]) {
139
167
  throw takeFromExternrefTable0(ret[1]);
@@ -162,11 +190,11 @@ exports.version = version;
162
190
  function __wbg_get_imports() {
163
191
  const import0 = {
164
192
  __proto__: null,
165
- __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
193
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
166
194
  const ret = Error(getStringFromWasm0(arg0, arg1));
167
195
  return ret;
168
196
  },
169
- __wbg_Number_14af1003b8dd5ead: function(arg0) {
197
+ __wbg_Number_ff192a72a0dcdf6d: function(arg0) {
170
198
  const ret = Number(arg0);
171
199
  return ret;
172
200
  },
@@ -174,88 +202,88 @@ function __wbg_get_imports() {
174
202
  const ret = String(arg1);
175
203
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
176
204
  const len1 = WASM_VECTOR_LEN;
177
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
178
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
205
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
206
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
179
207
  },
180
- __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
208
+ __wbg___wbindgen_boolean_get_4f1baf9a00be3c74: function(arg0) {
181
209
  const v = arg0;
182
210
  const ret = typeof(v) === 'boolean' ? v : undefined;
183
211
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
184
212
  },
185
- __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
213
+ __wbg___wbindgen_debug_string_f249a2a76caa9a55: function(arg0, arg1) {
186
214
  const ret = debugString(arg1);
187
215
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
216
  const len1 = WASM_VECTOR_LEN;
189
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
190
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
217
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
218
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
191
219
  },
192
- __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
220
+ __wbg___wbindgen_is_function_741ff2bb612836f5: function(arg0) {
193
221
  const ret = typeof(arg0) === 'function';
194
222
  return ret;
195
223
  },
196
- __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
224
+ __wbg___wbindgen_is_object_8b968c3ab8e96595: function(arg0) {
197
225
  const val = arg0;
198
226
  const ret = typeof(val) === 'object' && val !== null;
199
227
  return ret;
200
228
  },
201
- __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
229
+ __wbg___wbindgen_is_string_fc456fee5d3317de: function(arg0) {
202
230
  const ret = typeof(arg0) === 'string';
203
231
  return ret;
204
232
  },
205
- __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
233
+ __wbg___wbindgen_is_undefined_be5b34249ff1fc15: function(arg0) {
206
234
  const ret = arg0 === undefined;
207
235
  return ret;
208
236
  },
209
- __wbg___wbindgen_jsval_loose_eq_677f21e468d6b461: function(arg0, arg1) {
237
+ __wbg___wbindgen_jsval_loose_eq_b2f214e2e4b30e36: function(arg0, arg1) {
210
238
  const ret = arg0 == arg1;
211
239
  return ret;
212
240
  },
213
- __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
241
+ __wbg___wbindgen_number_get_934b640d0889af78: function(arg0, arg1) {
214
242
  const obj = arg1;
215
243
  const ret = typeof(obj) === 'number' ? obj : undefined;
216
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
217
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
244
+ getDataViewMemory0().setFloat64((arg0 >>> 0) + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
245
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, !isLikeNone(ret), true);
218
246
  },
219
- __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
247
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
220
248
  const obj = arg1;
221
249
  const ret = typeof(obj) === 'string' ? obj : undefined;
222
250
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
223
251
  var len1 = WASM_VECTOR_LEN;
224
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
225
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
252
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
253
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
226
254
  },
227
- __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
255
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
228
256
  throw new Error(getStringFromWasm0(arg0, arg1));
229
257
  },
230
- __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
258
+ __wbg_call_40b008ba32f73991: function() { return handleError(function (arg0, arg1) {
231
259
  const ret = arg0.call(arg1);
232
260
  return ret;
233
261
  }, arguments); },
234
- __wbg_done_b41a1d26cdb37fb6: function(arg0) {
262
+ __wbg_done_57e08d0be6e30c02: function(arg0) {
235
263
  const ret = arg0.done;
236
264
  return ret;
237
265
  },
238
- __wbg_entries_fb6397112b1de25f: function(arg0) {
266
+ __wbg_entries_7bb1459bd9b5c2b9: function(arg0) {
239
267
  const ret = Object.entries(arg0);
240
268
  return ret;
241
269
  },
242
- __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
270
+ __wbg_get_2080c49015e35254: function() { return handleError(function (arg0, arg1) {
243
271
  const ret = Reflect.get(arg0, arg1);
244
272
  return ret;
245
273
  }, arguments); },
246
- __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
274
+ __wbg_get_635eea311fa1a291: function() { return handleError(function (arg0, arg1) {
247
275
  const ret = Reflect.get(arg0, arg1);
248
276
  return ret;
249
277
  }, arguments); },
250
- __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
278
+ __wbg_get_d7176cfb76d71114: function(arg0, arg1) {
251
279
  const ret = arg0[arg1 >>> 0];
252
280
  return ret;
253
281
  },
254
- __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
282
+ __wbg_get_unchecked_e6325ad374eff861: function(arg0, arg1) {
255
283
  const ret = arg0[arg1 >>> 0];
256
284
  return ret;
257
285
  },
258
- __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
286
+ __wbg_instanceof_ArrayBuffer_12cdaa4161423e6b: function(arg0) {
259
287
  let result;
260
288
  try {
261
289
  result = arg0 instanceof ArrayBuffer;
@@ -265,7 +293,7 @@ function __wbg_get_imports() {
265
293
  const ret = result;
266
294
  return ret;
267
295
  },
268
- __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
296
+ __wbg_instanceof_Uint8Array_d7aeb0dcb3108fea: function(arg0) {
269
297
  let result;
270
298
  try {
271
299
  result = arg0 instanceof Uint8Array;
@@ -275,7 +303,7 @@ function __wbg_get_imports() {
275
303
  const ret = result;
276
304
  return ret;
277
305
  },
278
- __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
306
+ __wbg_instanceof_Window_5cf453f5639aa1a2: function(arg0) {
279
307
  let result;
280
308
  try {
281
309
  result = arg0 instanceof Window;
@@ -285,84 +313,84 @@ function __wbg_get_imports() {
285
313
  const ret = result;
286
314
  return ret;
287
315
  },
288
- __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
316
+ __wbg_isArray_bcf1376d0d732d08: function(arg0) {
289
317
  const ret = Array.isArray(arg0);
290
318
  return ret;
291
319
  },
292
- __wbg_isSafeInteger_717808ad6a54bd9e: function(arg0) {
320
+ __wbg_isSafeInteger_1a35ba4d31e71d38: function(arg0) {
293
321
  const ret = Number.isSafeInteger(arg0);
294
322
  return ret;
295
323
  },
296
- __wbg_iterator_e3c31c892080e444: function() {
324
+ __wbg_iterator_e4c5e8f68ada7b58: function() {
297
325
  const ret = Symbol.iterator;
298
326
  return ret;
299
327
  },
300
- __wbg_length_7f3c00c40364105e: function(arg0) {
328
+ __wbg_length_186163212ffe79c3: function(arg0) {
301
329
  const ret = arg0.length;
302
330
  return ret;
303
331
  },
304
- __wbg_length_d4bdea10311bd9cf: function(arg0) {
332
+ __wbg_length_b03a0fabb109b1e9: function(arg0) {
305
333
  const ret = arg0.length;
306
334
  return ret;
307
335
  },
308
- __wbg_navigator_2156486643462a87: function(arg0) {
336
+ __wbg_navigator_c17f443a6fe5d38d: function(arg0) {
309
337
  const ret = arg0.navigator;
310
338
  return ret;
311
339
  },
312
- __wbg_new_1dbf7428bba60a42: function(arg0) {
340
+ __wbg_new_13de428334042d26: function(arg0) {
313
341
  const ret = new Uint8Array(arg0);
314
342
  return ret;
315
343
  },
316
- __wbg_new_28744009d011f847: function() {
317
- const ret = new Map();
344
+ __wbg_new_37eb45aaf5eeb820: function() {
345
+ const ret = new Array();
318
346
  return ret;
319
347
  },
320
- __wbg_new_617a8cdb8bb1130e: function() {
321
- const ret = new Object();
348
+ __wbg_new_7075786089b89c5e: function() {
349
+ const ret = new Map();
322
350
  return ret;
323
351
  },
324
- __wbg_new_ee2291f50781bf1d: function() {
325
- const ret = new Array();
352
+ __wbg_new_cd4348290afae586: function() {
353
+ const ret = new Object();
326
354
  return ret;
327
355
  },
328
- __wbg_next_33784799010f1bbe: function(arg0) {
356
+ __wbg_next_178c1651c11432b3: function(arg0) {
329
357
  const ret = arg0.next;
330
358
  return ret;
331
359
  },
332
- __wbg_next_f4aac29c42af995c: function() { return handleError(function (arg0) {
360
+ __wbg_next_af5ac6a08bb0a717: function() { return handleError(function (arg0) {
333
361
  const ret = arg0.next();
334
362
  return ret;
335
363
  }, arguments); },
336
- __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
364
+ __wbg_prototypesetcall_13162965d1fe7aa3: function(arg0, arg1, arg2) {
337
365
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
338
366
  },
339
- __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
367
+ __wbg_set_8282f7e0d2d01336: function(arg0, arg1, arg2) {
340
368
  const ret = arg0.set(arg1, arg2);
341
369
  return ret;
342
370
  },
343
- __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
344
- arg0[arg1] = arg2;
345
- },
346
- __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
371
+ __wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
347
372
  arg0[arg1 >>> 0] = arg2;
348
373
  },
349
- __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
350
- const ret = typeof global === 'undefined' ? null : global;
374
+ __wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
375
+ arg0[arg1] = arg2;
376
+ },
377
+ __wbg_static_accessor_GLOBAL_THIS_003ee833af9699fc: function() {
378
+ const ret = typeof globalThis === 'undefined' ? undefined : globalThis;
351
379
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
352
380
  },
353
- __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
354
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
381
+ __wbg_static_accessor_GLOBAL_e4293fb22cbe77da: function() {
382
+ const ret = typeof global === 'undefined' ? undefined : global;
355
383
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
356
384
  },
357
- __wbg_static_accessor_SELF_0b583911f537483a: function() {
358
- const ret = typeof self === 'undefined' ? null : self;
385
+ __wbg_static_accessor_SELF_53bb20457401453d: function() {
386
+ const ret = typeof self === 'undefined' ? undefined : self;
359
387
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
360
388
  },
361
- __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
362
- const ret = typeof window === 'undefined' ? null : window;
389
+ __wbg_static_accessor_WINDOW_b5e0810bfecb7feb: function() {
390
+ const ret = typeof window === 'undefined' ? undefined : window;
363
391
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
364
392
  },
365
- __wbg_value_f3c585ee8f5ba40c: function(arg0) {
393
+ __wbg_value_e0f328965e184931: function(arg0) {
366
394
  const ret = arg0.value;
367
395
  return ret;
368
396
  },
@@ -388,12 +416,11 @@ function __wbg_get_imports() {
388
416
  },
389
417
  __wbindgen_init_externref_table: function() {
390
418
  const table = wasm.__wbindgen_externrefs;
391
- const offset = table.grow(4);
392
419
  table.set(0, undefined);
393
- table.set(offset + 0, undefined);
394
- table.set(offset + 1, null);
395
- table.set(offset + 2, true);
396
- table.set(offset + 3, false);
420
+ table.set(1024, undefined);
421
+ table.set(1025, null);
422
+ table.set(1026, true);
423
+ table.set(1027, false);
397
424
  },
398
425
  };
399
426
  return {
@@ -409,68 +436,61 @@ function addToExternrefTable0(obj) {
409
436
  }
410
437
 
411
438
  function debugString(val) {
412
- // primitive types
413
- const type = typeof val;
414
- if (type == 'number' || type == 'boolean' || val == null) {
415
- return `${val}`;
416
- }
417
- if (type == 'string') {
418
- return `"${val}"`;
419
- }
420
- if (type == 'symbol') {
421
- const description = val.description;
422
- if (description == null) {
423
- return 'Symbol';
424
- } else {
425
- return `Symbol(${description})`;
426
- }
427
- }
428
- if (type == 'function') {
429
- const name = val.name;
430
- if (typeof name == 'string' && name.length > 0) {
431
- return `Function(${name})`;
432
- } else {
433
- return 'Function';
434
- }
435
- }
436
- // objects
437
- if (Array.isArray(val)) {
438
- const length = val.length;
439
- let debug = '[';
440
- if (length > 0) {
441
- debug += debugString(val[0]);
442
- }
443
- for(let i = 1; i < length; i++) {
444
- debug += ', ' + debugString(val[i]);
445
- }
446
- debug += ']';
447
- return debug;
448
- }
449
- // Test for built-in
450
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
451
- let className;
452
- if (builtInMatches && builtInMatches.length > 1) {
453
- className = builtInMatches[1];
454
- } else {
455
- // Failed to match the standard '[object ClassName]'
456
- return toString.call(val);
457
- }
458
- if (className == 'Object') {
459
- // we're a user defined class or Object
460
- // JSON.stringify avoids problems with cycles, and is generally much
461
- // easier than looping through ownProperties of `val`.
462
- try {
463
- return 'Object(' + JSON.stringify(val) + ')';
464
- } catch (_) {
465
- return 'Object';
439
+ switch (typeof val) {
440
+ // primitive types
441
+ case 'number':
442
+ case 'boolean':
443
+ case 'undefined':
444
+ return `${val}`;
445
+ case 'string':
446
+ return JSON.stringify(val);
447
+ case 'bigint':
448
+ return `${val}n`;
449
+ case 'symbol':
450
+ return val.description !== undefined
451
+ ? `Symbol(${val.description})`
452
+ : 'Symbol';
453
+ case 'function':
454
+ return typeof val.name === 'string' && val.name !== ''
455
+ ? `Function(${val.name})`
456
+ : 'Function';
457
+ case 'object': {
458
+ if (val === null) {
459
+ return 'null';
460
+ }
461
+ // objects
462
+ if (Array.isArray(val)) {
463
+ return '[' + Array.from(val, debugString).join(', ') + ']';
464
+ }
465
+ // errors
466
+ if (val instanceof Error) {
467
+ return `${val.name}: ${val.message}\n${val.stack}`;
468
+ }
469
+
470
+ const toStringOutput = toString.call(val);
471
+ // Test for built-in
472
+ const className = /\[object ([^\]]+)\]/.exec(toStringOutput)?.[1];
473
+
474
+ // Failed to match the standard '[object ClassName]'
475
+ if (className === undefined) {
476
+ return toStringOutput;
477
+ }
478
+ if (className === 'Object') {
479
+ // we're a user defined class or Object
480
+ // JSON.stringify avoids problems with cycles, and is generally much
481
+ // easier than looping through ownProperties of `val`.
482
+ try {
483
+ return 'Object(' + JSON.stringify(val) + ')';
484
+ } catch (_) {
485
+ return 'Object';
486
+ }
487
+ }
488
+ // TODO we could test for more things here, like `Set`s and `Map`s.
489
+ return className;
466
490
  }
491
+ // Per MDN: 'This list of values is exhaustive.'
492
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#description
467
493
  }
468
- // errors
469
- if (val instanceof Error) {
470
- return `${val.name}: ${val.message}\n${val.stack}`;
471
- }
472
- // TODO we could test for more things here, like `Set`s and `Map`s.
473
- return className;
474
494
  }
475
495
 
476
496
  function getArrayU8FromWasm0(ptr, len) {
@@ -487,7 +507,8 @@ function getDataViewMemory0() {
487
507
  }
488
508
 
489
509
  function getStringFromWasm0(ptr, len) {
490
- return decodeText(ptr >>> 0, len);
510
+ ptr = ptr >>> 0;
511
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
491
512
  }
492
513
 
493
514
  let cachedUint8ArrayMemory0 = null;
@@ -561,10 +582,10 @@ function takeFromExternrefTable0(idx) {
561
582
  return value;
562
583
  }
563
584
 
564
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
585
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
565
586
  cachedTextDecoder.decode();
566
- function decodeText(ptr, len) {
567
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
587
+ function decodeText(bytes) {
588
+ return cachedTextDecoder.decode(bytes);
568
589
  }
569
590
 
570
591
  const cachedTextEncoder = new TextEncoder();
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Gregory Beurier <gregory.beurier@cirad.fr>"
5
5
  ],
6
6
  "description": "WebAssembly bindings for nirs4all-formats.",
7
- "version": "0.2.13",
7
+ "version": "0.2.14",
8
8
  "license": "CECILL-2.1 OR AGPL-3.0-or-later",
9
9
  "repository": {
10
10
  "type": "git",