@earthyscience/netcdf4-wasm 0.3.0 → 0.4.0

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 (56) hide show
  1. package/CONTRIBUTING.md +29 -22
  2. package/README.md +12 -10
  3. package/dist/constants.d.ts +165 -146
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/constants.js +48 -60
  6. package/dist/constants.js.map +1 -1
  7. package/dist/dimension.js +1 -1
  8. package/dist/errors.d.ts +3 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +15 -0
  11. package/dist/errors.js.map +1 -0
  12. package/dist/group.d.ts +4 -5
  13. package/dist/group.d.ts.map +1 -1
  14. package/dist/group.js +11 -70
  15. package/dist/group.js.map +1 -1
  16. package/dist/index.d.ts +15 -16
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +13 -14
  19. package/dist/index.js.map +1 -1
  20. package/dist/netcdf-getters.d.ts +5 -5
  21. package/dist/netcdf-getters.d.ts.map +1 -1
  22. package/dist/netcdf-getters.js +78 -50
  23. package/dist/netcdf-getters.js.map +1 -1
  24. package/dist/netcdf-worker.js +15 -105
  25. package/dist/netcdf-worker.js.map +1 -1
  26. package/dist/netcdf4-wasm.js +2 -2
  27. package/dist/netcdf4-wasm.wasm +0 -0
  28. package/dist/netcdf4.d.ts +19 -20
  29. package/dist/netcdf4.d.ts.map +1 -1
  30. package/dist/netcdf4.js +201 -518
  31. package/dist/netcdf4.js.map +1 -1
  32. package/dist/operations.d.ts +67 -0
  33. package/dist/operations.d.ts.map +1 -0
  34. package/dist/operations.js +57 -0
  35. package/dist/operations.js.map +1 -0
  36. package/dist/remote-read.d.ts +4 -4
  37. package/dist/remote-read.d.ts.map +1 -1
  38. package/dist/remote-read.js +22 -18
  39. package/dist/remote-read.js.map +1 -1
  40. package/dist/slice.d.ts.map +1 -1
  41. package/dist/slice.js.map +1 -1
  42. package/dist/types.d.ts +27 -414
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/variable.d.ts +1 -1
  45. package/dist/variable.d.ts.map +1 -1
  46. package/dist/variable.js +60 -78
  47. package/dist/variable.js.map +1 -1
  48. package/dist/wasm-module.d.ts +468 -2
  49. package/dist/wasm-module.d.ts.map +1 -1
  50. package/dist/wasm-module.js +331 -251
  51. package/dist/wasm-module.js.map +1 -1
  52. package/package.json +17 -14
  53. package/dist/test-setup.d.ts +0 -13
  54. package/dist/test-setup.d.ts.map +0 -1
  55. package/dist/test-setup.js +0 -78
  56. package/dist/test-setup.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  // WASM module loading and wrapping functionality
2
- import { NC_CONSTANTS, DATA_TYPE_SIZE } from './constants.js';
2
+ import { DATA_TYPE_SIZE, NC_CONSTANTS } from "./constants.js";
3
3
  const NC_MAX_NAME = 256;
4
4
  const NC_MAX_DIMS = 1024;
5
5
  const NC_MAX_VARS = 8192;
@@ -10,7 +10,7 @@ function stridedLength(count) {
10
10
  // Throws a RangeError if the allocation would be unsafe.
11
11
  function safeByteLength(totalLength, elementSize) {
12
12
  const byteLength = totalLength * elementSize;
13
- if (byteLength > 0xFFFFFFFF) {
13
+ if (byteLength > 0xffffffff) {
14
14
  throw new RangeError(`Allocation size ${byteLength} exceeds WASM32 heap limit (0xFFFFFFFF). ` +
15
15
  `Requested ${totalLength} elements of ${elementSize} bytes each.`);
16
16
  }
@@ -19,20 +19,20 @@ function safeByteLength(totalLength, elementSize) {
19
19
  export class WasmModuleLoader {
20
20
  static async loadModule(options = {}) {
21
21
  try {
22
- if (typeof window === 'undefined') {
23
- throw new Error('NetCDF4-WASM only works in browser environments.');
22
+ if (typeof window === "undefined") {
23
+ throw new Error("NetCDF4-WASM only works in browser environments.");
24
24
  }
25
25
  // Dynamically import the generated netcdf4-wasm.js module
26
- const netcdf4Module = await import('./netcdf4-wasm.js');
26
+ const netcdf4Module = await import("./netcdf4-wasm.js");
27
27
  const createNetCDF4Module = netcdf4Module.default;
28
28
  // Use the imported module factory
29
29
  const rawModule = await createNetCDF4Module({
30
30
  locateFile: (file) => {
31
- if (file.endsWith('.wasm')) {
32
- return options.wasmPath || './netcdf4-wasm.wasm';
31
+ if (file.endsWith(".wasm")) {
32
+ return options.wasmPath || "./netcdf4-wasm.wasm";
33
33
  }
34
34
  return file;
35
- }
35
+ },
36
36
  });
37
37
  // Wrap the module with high-level functions
38
38
  return WasmModuleLoader.wrapModule(rawModule);
@@ -44,128 +44,152 @@ export class WasmModuleLoader {
44
44
  static wrapModule(module) {
45
45
  // Create wrappers for NetCDF functions
46
46
  // https://docs.unidata.ucar.edu/netcdf-c/current/group__variables.html#details
47
- const nc_open_wrapper = module.cwrap('nc_open_wrapper', 'number', ['string', 'number', 'number']);
48
- const nc_close_wrapper = module.cwrap('nc_close_wrapper', 'number', ['number']);
49
- const nc_create_wrapper = module.cwrap('nc_create_wrapper', 'number', ['string', 'number', 'number']);
50
- const nc_def_dim_wrapper = module.cwrap('nc_def_dim_wrapper', 'number', ['number', 'string', 'number', 'number']);
51
- const nc_def_var_wrapper = module.cwrap('nc_def_var_wrapper', 'number', ['number', 'string', 'number', 'number', 'number', 'number']);
52
- const nc_put_var_double_wrapper = module.cwrap('nc_put_var_double_wrapper', 'number', ['number', 'number', 'number']);
47
+ const nc_open_wrapper = module.cwrap("nc_open_wrapper", "number", [
48
+ "string",
49
+ "number",
50
+ "number",
51
+ ]);
52
+ const nc_close_wrapper = module.cwrap("nc_close_wrapper", "number", [
53
+ "number",
54
+ ]);
55
+ const nc_create_wrapper = module.cwrap("nc_create_wrapper", "number", [
56
+ "string",
57
+ "number",
58
+ "number",
59
+ ]);
60
+ const nc_def_dim_wrapper = module.cwrap("nc_def_dim_wrapper", "number", ["number", "string", "number", "number"]);
61
+ const nc_def_var_wrapper = module.cwrap("nc_def_var_wrapper", "number", ["number", "string", "number", "number", "number", "number"]);
62
+ const nc_put_var_double_wrapper = module.cwrap("nc_put_var_double_wrapper", "number", ["number", "number", "number"]);
53
63
  // const nc_get_var_double_wrapper = module.cwrap('nc_get_var_double_wrapper', 'number', ['number', 'number', 'number']);
54
- const nc_enddef_wrapper = module.cwrap('nc_enddef_wrapper', 'number', ['number']);
64
+ const nc_enddef_wrapper = module.cwrap("nc_enddef_wrapper", "number", [
65
+ "number",
66
+ ]);
55
67
  // Dimension inquiry wrappers
56
- const nc_inq_ndims_wrapper = module.cwrap('nc_inq_ndims_wrapper', 'number', ['number', 'number']);
57
- const nc_inq_unlimdim_wrapper = module.cwrap('nc_inq_unlimdim_wrapper', 'number', ['number', 'number']);
58
- const nc_inq_dimids_wrapper = module.cwrap('nc_inq_dimids_wrapper', 'number', ['number', 'number', 'number', 'number']);
59
- const nc_inq_dim_wrapper = module.cwrap('nc_inq_dim_wrapper', 'number', ['number', 'number', 'number', 'number']);
60
- const nc_inq_dimid_wrapper = module.cwrap('nc_inq_dimid_wrapper', 'number', ['number', 'string', 'number']);
61
- const nc_inq_dimlen_wrapper = module.cwrap('nc_inq_dimlen_wrapper', 'number', ['number', 'number', 'number']);
62
- const nc_inq_dimname_wrapper = module.cwrap('nc_inq_dimname_wrapper', 'number', ['number', 'number', 'number']);
68
+ const nc_inq_ndims_wrapper = module.cwrap("nc_inq_ndims_wrapper", "number", ["number", "number"]);
69
+ const nc_inq_unlimdim_wrapper = module.cwrap("nc_inq_unlimdim_wrapper", "number", ["number", "number"]);
70
+ const nc_inq_dimids_wrapper = module.cwrap("nc_inq_dimids_wrapper", "number", ["number", "number", "number", "number"]);
71
+ const nc_inq_dim_wrapper = module.cwrap("nc_inq_dim_wrapper", "number", ["number", "number", "number", "number"]);
72
+ const nc_inq_dimid_wrapper = module.cwrap("nc_inq_dimid_wrapper", "number", ["number", "string", "number"]);
73
+ const nc_inq_dimlen_wrapper = module.cwrap("nc_inq_dimlen_wrapper", "number", ["number", "number", "number"]);
74
+ const nc_inq_dimname_wrapper = module.cwrap("nc_inq_dimname_wrapper", "number", ["number", "number", "number"]);
63
75
  // Variable inquiry wrappers
64
- const nc_inq_nvars_wrapper = module.cwrap('nc_inq_nvars_wrapper', 'number', ['number', 'number']);
65
- const nc_inq_varids_wrapper = module.cwrap('nc_inq_varids_wrapper', 'number', ['number', 'number', 'number']);
66
- const nc_inq_varid_wrapper = module.cwrap('nc_inq_varid_wrapper', 'number', ['number', 'string', 'number']);
67
- const nc_inq_var_wrapper = module.cwrap('nc_inq_var_wrapper', 'number', [
68
- 'number', 'number', // ncid, varid
69
- 'number', // name pointer
70
- 'number', 'number', 'number', 'number' // typep, ndimsp, dimidsp, nattsp
76
+ const nc_inq_nvars_wrapper = module.cwrap("nc_inq_nvars_wrapper", "number", ["number", "number"]);
77
+ const nc_inq_varids_wrapper = module.cwrap("nc_inq_varids_wrapper", "number", ["number", "number", "number"]);
78
+ const nc_inq_varid_wrapper = module.cwrap("nc_inq_varid_wrapper", "number", ["number", "string", "number"]);
79
+ const nc_inq_var_wrapper = module.cwrap("nc_inq_var_wrapper", "number", [
80
+ "number",
81
+ "number", // ncid, varid
82
+ "number", // name pointer
83
+ "number",
84
+ "number",
85
+ "number",
86
+ "number", // typep, ndimsp, dimidsp, nattsp
71
87
  ]);
72
88
  // Variable inquiry wrappers
73
- const nc_inq_varname_wrapper = module.cwrap('nc_inq_varname_wrapper', 'number', ['number', 'number', 'number']);
74
- const nc_inq_vartype_wrapper = module.cwrap('nc_inq_vartype_wrapper', 'number', ['number', 'number', 'number']);
75
- const nc_inq_varndims_wrapper = module.cwrap('nc_inq_varndims_wrapper', 'number', ['number', 'number', 'number']);
76
- const nc_inq_vardimid_wrapper = module.cwrap('nc_inq_vardimid_wrapper', 'number', ['number', 'number', 'number']);
77
- const nc_inq_varnatts_wrapper = module.cwrap('nc_inq_varnatts_wrapper', 'number', ['number', 'number', 'number']);
78
- const nc_inq_var_chunking_wrapper = module.cwrap('nc_inq_var_chunking_wrapper', 'number', ['number', 'number', 'number', 'number']);
89
+ const nc_inq_varname_wrapper = module.cwrap("nc_inq_varname_wrapper", "number", ["number", "number", "number"]);
90
+ const nc_inq_vartype_wrapper = module.cwrap("nc_inq_vartype_wrapper", "number", ["number", "number", "number"]);
91
+ const nc_inq_varndims_wrapper = module.cwrap("nc_inq_varndims_wrapper", "number", ["number", "number", "number"]);
92
+ const nc_inq_vardimid_wrapper = module.cwrap("nc_inq_vardimid_wrapper", "number", ["number", "number", "number"]);
93
+ const nc_inq_varnatts_wrapper = module.cwrap("nc_inq_varnatts_wrapper", "number", ["number", "number", "number"]);
94
+ const nc_inq_var_chunking_wrapper = module.cwrap("nc_inq_var_chunking_wrapper", "number", ["number", "number", "number", "number"]);
79
95
  // Attribute inquiry wrappers
80
- const nc_inq_natts_wrapper = module.cwrap('nc_inq_natts_wrapper', 'number', ['number', 'number']);
81
- const nc_inq_att_wrapper = module.cwrap('nc_inq_att_wrapper', 'number', ['number', 'number', 'string', 'number', 'number']);
82
- const nc_inq_attid_wrapper = module.cwrap('nc_inq_attid_wrapper', 'number', ['number', 'number', 'string', 'number']);
83
- const nc_inq_attname_wrapper = module.cwrap('nc_inq_attname_wrapper', 'number', ['number', 'number', 'number', 'number']);
84
- const nc_inq_atttype_wrapper = module.cwrap('nc_inq_atttype_wrapper', 'number', ['number', 'number', 'string', 'number']);
85
- const nc_inq_attlen_wrapper = module.cwrap('nc_inq_attlen_wrapper', 'number', ['number', 'number', 'string', 'number']);
96
+ const nc_inq_natts_wrapper = module.cwrap("nc_inq_natts_wrapper", "number", ["number", "number"]);
97
+ const nc_inq_att_wrapper = module.cwrap("nc_inq_att_wrapper", "number", ["number", "number", "string", "number", "number"]);
98
+ const nc_inq_attid_wrapper = module.cwrap("nc_inq_attid_wrapper", "number", ["number", "number", "string", "number"]);
99
+ const nc_inq_attname_wrapper = module.cwrap("nc_inq_attname_wrapper", "number", ["number", "number", "number", "number"]);
100
+ const nc_inq_atttype_wrapper = module.cwrap("nc_inq_atttype_wrapper", "number", ["number", "number", "string", "number"]);
101
+ const nc_inq_attlen_wrapper = module.cwrap("nc_inq_attlen_wrapper", "number", ["number", "number", "string", "number"]);
86
102
  // Attribute getters
87
- const nc_get_att_text_wrapper = module.cwrap('nc_get_att_text_wrapper', 'number', ['number', 'number', 'string', 'number']);
88
- const nc_get_att_short_wrapper = module.cwrap('nc_get_att_short_wrapper', 'number', ['number', 'number', 'string', 'number']);
89
- const nc_get_att_int_wrapper = module.cwrap('nc_get_att_int_wrapper', 'number', ['number', 'number', 'string', 'number']);
90
- const nc_get_att_float_wrapper = module.cwrap('nc_get_att_float_wrapper', 'number', ['number', 'number', 'string', 'number']);
91
- const nc_get_att_double_wrapper = module.cwrap('nc_get_att_double_wrapper', 'number', ['number', 'number', 'string', 'number']);
92
- const nc_get_att_longlong_wrapper = module.cwrap('nc_get_att_longlong_wrapper', 'number', ['number', 'number', 'string', 'number']);
93
- const nc_get_att_string_wrapper = module.cwrap('nc_get_att_string_wrapper', 'number', ['number', 'number', 'string', 'number']);
94
- const nc_free_string_wrapper = module.cwrap('nc_free_string_wrapper', 'number', ['number', 'number']);
95
- const nc_get_att_schar_wrapper = module.cwrap('nc_get_att_schar_wrapper', 'number', ['number', 'number', 'string', 'number']);
103
+ const nc_get_att_text_wrapper = module.cwrap("nc_get_att_text_wrapper", "number", ["number", "number", "string", "number"]);
104
+ const nc_get_att_short_wrapper = module.cwrap("nc_get_att_short_wrapper", "number", ["number", "number", "string", "number"]);
105
+ const nc_get_att_int_wrapper = module.cwrap("nc_get_att_int_wrapper", "number", ["number", "number", "string", "number"]);
106
+ const nc_get_att_float_wrapper = module.cwrap("nc_get_att_float_wrapper", "number", ["number", "number", "string", "number"]);
107
+ const nc_get_att_double_wrapper = module.cwrap("nc_get_att_double_wrapper", "number", ["number", "number", "string", "number"]);
108
+ const nc_get_att_longlong_wrapper = module.cwrap("nc_get_att_longlong_wrapper", "number", ["number", "number", "string", "number"]);
109
+ const nc_get_att_string_wrapper = module.cwrap("nc_get_att_string_wrapper", "number", ["number", "number", "string", "number"]);
110
+ const nc_free_string_wrapper = module.cwrap("nc_free_string_wrapper", "number", ["number", "number"]);
111
+ const nc_get_att_schar_wrapper = module.cwrap("nc_get_att_schar_wrapper", "number", ["number", "number", "string", "number"]);
96
112
  // 8-bit unsigned
97
- const nc_get_att_uchar_wrapper = module.cwrap('nc_get_att_uchar_wrapper', 'number', ['number', 'number', 'string', 'number']);
113
+ const nc_get_att_uchar_wrapper = module.cwrap("nc_get_att_uchar_wrapper", "number", ["number", "number", "string", "number"]);
98
114
  // 16-bit unsigned
99
- const nc_get_att_ushort_wrapper = module.cwrap('nc_get_att_ushort_wrapper', 'number', ['number', 'number', 'string', 'number']);
115
+ const nc_get_att_ushort_wrapper = module.cwrap("nc_get_att_ushort_wrapper", "number", ["number", "number", "string", "number"]);
100
116
  // 32-bit unsigned
101
- const nc_get_att_uint_wrapper = module.cwrap('nc_get_att_uint_wrapper', 'number', ['number', 'number', 'string', 'number']);
117
+ const nc_get_att_uint_wrapper = module.cwrap("nc_get_att_uint_wrapper", "number", ["number", "number", "string", "number"]);
102
118
  // 64-bit unsigned
103
- const nc_get_att_ulonglong_wrapper = module.cwrap('nc_get_att_ulonglong_wrapper', 'number', ['number', 'number', 'string', 'number']);
119
+ const nc_get_att_ulonglong_wrapper = module.cwrap("nc_get_att_ulonglong_wrapper", "number", ["number", "number", "string", "number"]);
104
120
  // Variable getters
105
- const nc_get_vara_short_wrapper = module.cwrap('nc_get_vara_short_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
106
- const nc_get_vara_int_wrapper = module.cwrap('nc_get_vara_int_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
107
- const nc_get_vara_float_wrapper = module.cwrap('nc_get_vara_float_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
108
- const nc_get_vara_double_wrapper = module.cwrap('nc_get_vara_double_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
109
- const nc_get_vara_longlong_wrapper = module.cwrap('nc_get_vara_longlong_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
110
- const nc_get_vara_schar_wrapper = module.cwrap('nc_get_vara_schar_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
111
- const nc_get_vara_uchar_wrapper = module.cwrap('nc_get_vara_uchar_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
112
- const nc_get_vara_ushort_wrapper = module.cwrap('nc_get_vara_ushort_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
113
- const nc_get_vara_uint_wrapper = module.cwrap('nc_get_vara_uint_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
114
- const nc_get_vara_ulonglong_wrapper = module.cwrap('nc_get_vara_ulonglong_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
115
- const nc_get_vara_string_wrapper = module.cwrap('nc_get_vara_string_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
116
- const nc_get_var_text_wrapper = module.cwrap('nc_get_var_text_wrapper', 'number', ['number', 'number', 'number']);
117
- const nc_get_var_short_wrapper = module.cwrap('nc_get_var_short_wrapper', 'number', ['number', 'number', 'number']);
118
- const nc_get_var_int_wrapper = module.cwrap('nc_get_var_int_wrapper', 'number', ['number', 'number', 'number']);
119
- const nc_get_var_longlong_wrapper = module.cwrap('nc_get_var_longlong_wrapper', 'number', ['number', 'number', 'number']);
120
- const nc_get_var_float_wrapper = module.cwrap('nc_get_var_float_wrapper', 'number', ['number', 'number', 'number']);
121
- const nc_get_var_double_wrapper = module.cwrap('nc_get_var_double_wrapper', 'number', ['number', 'number', 'number']);
122
- const nc_get_var_schar_wrapper = module.cwrap('nc_get_var_schar_wrapper', 'number', ['number', 'number', 'number']);
123
- const nc_get_var_uchar_wrapper = module.cwrap('nc_get_var_uchar_wrapper', 'number', ['number', 'number', 'number']);
124
- const nc_get_var_ushort_wrapper = module.cwrap('nc_get_var_ushort_wrapper', 'number', ['number', 'number', 'number']);
125
- const nc_get_var_uint_wrapper = module.cwrap('nc_get_var_uint_wrapper', 'number', ['number', 'number', 'number']);
126
- const nc_get_var_ulonglong_wrapper = module.cwrap('nc_get_var_ulonglong_wrapper', 'number', ['number', 'number', 'number']);
127
- const nc_get_var_string_wrapper = module.cwrap('nc_get_var_string_wrapper', 'number', ['number', 'number', 'number']);
121
+ const nc_get_vara_short_wrapper = module.cwrap("nc_get_vara_short_wrapper", "number", ["number", "number", "number", "number", "number"]);
122
+ const nc_get_vara_int_wrapper = module.cwrap("nc_get_vara_int_wrapper", "number", ["number", "number", "number", "number", "number"]);
123
+ const nc_get_vara_float_wrapper = module.cwrap("nc_get_vara_float_wrapper", "number", ["number", "number", "number", "number", "number"]);
124
+ const nc_get_vara_double_wrapper = module.cwrap("nc_get_vara_double_wrapper", "number", ["number", "number", "number", "number", "number"]);
125
+ const nc_get_vara_longlong_wrapper = module.cwrap("nc_get_vara_longlong_wrapper", "number", ["number", "number", "number", "number", "number"]);
126
+ const nc_get_vara_schar_wrapper = module.cwrap("nc_get_vara_schar_wrapper", "number", ["number", "number", "number", "number", "number"]);
127
+ const nc_get_vara_uchar_wrapper = module.cwrap("nc_get_vara_uchar_wrapper", "number", ["number", "number", "number", "number", "number"]);
128
+ const nc_get_vara_ushort_wrapper = module.cwrap("nc_get_vara_ushort_wrapper", "number", ["number", "number", "number", "number", "number"]);
129
+ const nc_get_vara_uint_wrapper = module.cwrap("nc_get_vara_uint_wrapper", "number", ["number", "number", "number", "number", "number"]);
130
+ const nc_get_vara_ulonglong_wrapper = module.cwrap("nc_get_vara_ulonglong_wrapper", "number", ["number", "number", "number", "number", "number"]);
131
+ const nc_get_vara_string_wrapper = module.cwrap("nc_get_vara_string_wrapper", "number", ["number", "number", "number", "number", "number"]);
132
+ const nc_get_var_text_wrapper = module.cwrap("nc_get_var_text_wrapper", "number", ["number", "number", "number"]);
133
+ const nc_get_var_short_wrapper = module.cwrap("nc_get_var_short_wrapper", "number", ["number", "number", "number"]);
134
+ const nc_get_var_int_wrapper = module.cwrap("nc_get_var_int_wrapper", "number", ["number", "number", "number"]);
135
+ const nc_get_var_longlong_wrapper = module.cwrap("nc_get_var_longlong_wrapper", "number", ["number", "number", "number"]);
136
+ const nc_get_var_float_wrapper = module.cwrap("nc_get_var_float_wrapper", "number", ["number", "number", "number"]);
137
+ const nc_get_var_double_wrapper = module.cwrap("nc_get_var_double_wrapper", "number", ["number", "number", "number"]);
138
+ const nc_get_var_schar_wrapper = module.cwrap("nc_get_var_schar_wrapper", "number", ["number", "number", "number"]);
139
+ const nc_get_var_uchar_wrapper = module.cwrap("nc_get_var_uchar_wrapper", "number", ["number", "number", "number"]);
140
+ const nc_get_var_ushort_wrapper = module.cwrap("nc_get_var_ushort_wrapper", "number", ["number", "number", "number"]);
141
+ const nc_get_var_uint_wrapper = module.cwrap("nc_get_var_uint_wrapper", "number", ["number", "number", "number"]);
142
+ const nc_get_var_ulonglong_wrapper = module.cwrap("nc_get_var_ulonglong_wrapper", "number", ["number", "number", "number"]);
143
+ const nc_get_var_string_wrapper = module.cwrap("nc_get_var_string_wrapper", "number", ["number", "number", "number"]);
128
144
  // Stride inquiry wrappers
129
- const nc_get_vars_schar_wrapper = module.cwrap('nc_get_vars_schar_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
130
- const nc_get_vars_uchar_wrapper = module.cwrap('nc_get_vars_uchar_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
131
- const nc_get_vars_short_wrapper = module.cwrap('nc_get_vars_short_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
132
- const nc_get_vars_ushort_wrapper = module.cwrap('nc_get_vars_ushort_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
133
- const nc_get_vars_int_wrapper = module.cwrap('nc_get_vars_int_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
134
- const nc_get_vars_uint_wrapper = module.cwrap('nc_get_vars_uint_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
135
- const nc_get_vars_float_wrapper = module.cwrap('nc_get_vars_float_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
136
- const nc_get_vars_double_wrapper = module.cwrap('nc_get_vars_double_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
137
- const nc_get_vars_longlong_wrapper = module.cwrap('nc_get_vars_longlong_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
138
- const nc_get_vars_ulonglong_wrapper = module.cwrap('nc_get_vars_ulonglong_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
139
- const nc_get_vars_string_wrapper = module.cwrap('nc_get_vars_string_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
140
- const nc_get_vars_wrapper = module.cwrap('nc_get_vars_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
141
- const nc_get_vars_text_wrapper = module.cwrap('nc_get_vars_text_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
145
+ const nc_get_vars_schar_wrapper = module.cwrap("nc_get_vars_schar_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
146
+ const nc_get_vars_uchar_wrapper = module.cwrap("nc_get_vars_uchar_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
147
+ const nc_get_vars_short_wrapper = module.cwrap("nc_get_vars_short_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
148
+ const nc_get_vars_ushort_wrapper = module.cwrap("nc_get_vars_ushort_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
149
+ const nc_get_vars_int_wrapper = module.cwrap("nc_get_vars_int_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
150
+ const nc_get_vars_uint_wrapper = module.cwrap("nc_get_vars_uint_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
151
+ const nc_get_vars_float_wrapper = module.cwrap("nc_get_vars_float_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
152
+ const nc_get_vars_double_wrapper = module.cwrap("nc_get_vars_double_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
153
+ const nc_get_vars_longlong_wrapper = module.cwrap("nc_get_vars_longlong_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
154
+ const nc_get_vars_ulonglong_wrapper = module.cwrap("nc_get_vars_ulonglong_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
155
+ const nc_get_vars_string_wrapper = module.cwrap("nc_get_vars_string_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
156
+ const nc_get_vars_wrapper = module.cwrap("nc_get_vars_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
157
+ const nc_get_vars_text_wrapper = module.cwrap("nc_get_vars_text_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
142
158
  // const nc_get_vars_as_type_wrapper = module.cwrap('nc_get_vars_as_type_wrapper', 'number', ['number','number','number','number','number','number','number']);
143
159
  // Group inquiry wrappers
144
- const nc_inq_grps_wrapper = module.cwrap('nc_inq_grps_wrapper', 'number', ['number', 'number', 'number']);
145
- const nc_inq_grp_ncid_wrapper = module.cwrap('nc_inq_grp_ncid_wrapper', 'number', ['number', 'string', 'number']);
146
- const nc_inq_grpname_wrapper = module.cwrap('nc_inq_grpname_wrapper', 'number', ['number', 'number']);
147
- const nc_inq_grp_parent_wrapper = module.cwrap('nc_inq_grp_parent_wrapper', 'number', ['number', 'number']);
148
- const nc_inq_grp_full_ncid_wrapper = module.cwrap('nc_inq_grp_full_ncid_wrapper', 'number', ['number', 'string', 'number']);
149
- const nc_inq_grpname_full_wrapper = module.cwrap('nc_inq_grpname_full_wrapper', 'number', ['number', 'number', 'number']);
150
- const nc_inq_grpname_len_wrapper = module.cwrap('nc_inq_grpname_len_wrapper', 'number', ['number', 'number']);
160
+ const nc_inq_grps_wrapper = module.cwrap("nc_inq_grps_wrapper", "number", ["number", "number", "number"]);
161
+ const nc_inq_grp_ncid_wrapper = module.cwrap("nc_inq_grp_ncid_wrapper", "number", ["number", "string", "number"]);
162
+ const nc_inq_grpname_wrapper = module.cwrap("nc_inq_grpname_wrapper", "number", ["number", "number"]);
163
+ const nc_inq_grp_parent_wrapper = module.cwrap("nc_inq_grp_parent_wrapper", "number", ["number", "number"]);
164
+ const nc_inq_grp_full_ncid_wrapper = module.cwrap("nc_inq_grp_full_ncid_wrapper", "number", ["number", "string", "number"]);
165
+ const nc_inq_grpname_full_wrapper = module.cwrap("nc_inq_grpname_full_wrapper", "number", ["number", "number", "number"]);
166
+ const nc_inq_grpname_len_wrapper = module.cwrap("nc_inq_grpname_len_wrapper", "number", ["number", "number"]);
151
167
  // enum wrappers
152
- const nc_inq_typeids_wrapper = module.cwrap('nc_inq_typeids_wrapper', 'number', ['number', 'number', 'number']);
153
- const nc_inq_type_wrapper = module.cwrap('nc_inq_type_wrapper', 'number', ['number', 'number', 'number', 'number']);
154
- const nc_inq_user_type_wrapper = module.cwrap('nc_inq_user_type_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number']);
155
- const nc_def_enum_wrapper = module.cwrap('nc_def_enum_wrapper', 'number', ['number', 'number', 'string', 'number']);
156
- const nc_insert_enum_wrapper = module.cwrap('nc_insert_enum_wrapper', 'number', ['number', 'number', 'string', 'number']);
157
- const nc_inq_enum_wrapper = module.cwrap('nc_inq_enum_wrapper', 'number', ['number', 'number', 'number', 'number', 'number', 'number']);
158
- const nc_inq_enum_member_wrapper = module.cwrap('nc_inq_enum_member_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
159
- const nc_inq_enum_ident_wrapper = module.cwrap('nc_inq_enum_ident_wrapper', 'number', ['number', 'number', 'number', 'number']);
168
+ const nc_inq_typeids_wrapper = module.cwrap("nc_inq_typeids_wrapper", "number", ["number", "number", "number"]);
169
+ const nc_inq_type_wrapper = module.cwrap("nc_inq_type_wrapper", "number", ["number", "number", "number", "number"]);
170
+ const nc_inq_user_type_wrapper = module.cwrap("nc_inq_user_type_wrapper", "number", [
171
+ "number",
172
+ "number",
173
+ "number",
174
+ "number",
175
+ "number",
176
+ "number",
177
+ "number",
178
+ ]);
179
+ const nc_def_enum_wrapper = module.cwrap("nc_def_enum_wrapper", "number", ["number", "number", "string", "number"]);
180
+ const nc_insert_enum_wrapper = module.cwrap("nc_insert_enum_wrapper", "number", ["number", "number", "string", "number"]);
181
+ const nc_inq_enum_wrapper = module.cwrap("nc_inq_enum_wrapper", "number", ["number", "number", "number", "number", "number", "number"]);
182
+ const nc_inq_enum_member_wrapper = module.cwrap("nc_inq_enum_member_wrapper", "number", ["number", "number", "number", "number", "number"]);
183
+ const nc_inq_enum_ident_wrapper = module.cwrap("nc_inq_enum_ident_wrapper", "number", ["number", "number", "number", "number"]);
160
184
  // generic type inquiry wrapper
161
- const nc_get_var_wrapper = module.cwrap('nc_get_var_wrapper', 'number', ['number', 'number', 'number']);
162
- const nc_get_vara_wrapper = module.cwrap('nc_get_vara_wrapper', 'number', ['number', 'number', 'number', 'number', 'number']);
185
+ const nc_get_var_wrapper = module.cwrap("nc_get_var_wrapper", "number", ["number", "number", "number"]);
186
+ const nc_get_vara_wrapper = module.cwrap("nc_get_vara_wrapper", "number", ["number", "number", "number", "number", "number"]);
163
187
  return {
164
188
  ...module,
165
189
  nc_open: (path, mode) => {
166
190
  const ncidPtr = module._malloc(4);
167
191
  const result = nc_open_wrapper(path, mode, ncidPtr);
168
- const ncid = module.getValue(ncidPtr, 'i32');
192
+ const ncid = module.getValue(ncidPtr, "i32");
169
193
  module._free(ncidPtr);
170
194
  return { result, ncid };
171
195
  },
@@ -175,7 +199,7 @@ export class WasmModuleLoader {
175
199
  nc_create: (path, mode) => {
176
200
  const ncidPtr = module._malloc(4);
177
201
  const result = nc_create_wrapper(path, mode, ncidPtr);
178
- const ncid = module.getValue(ncidPtr, 'i32');
202
+ const ncid = module.getValue(ncidPtr, "i32");
179
203
  module._free(ncidPtr);
180
204
  return { result, ncid };
181
205
  },
@@ -183,14 +207,18 @@ export class WasmModuleLoader {
183
207
  nc_inq_ndims: (ncid) => {
184
208
  const ndimsPtr = module._malloc(4);
185
209
  const result = nc_inq_ndims_wrapper(ncid, ndimsPtr);
186
- const ndims = result === NC_CONSTANTS.NC_NOERR ? module.getValue(ndimsPtr, 'i32') : undefined;
210
+ const ndims = result === NC_CONSTANTS.NC_NOERR
211
+ ? module.getValue(ndimsPtr, "i32")
212
+ : undefined;
187
213
  module._free(ndimsPtr);
188
214
  return { result, ndims };
189
215
  },
190
216
  nc_inq_unlimdim: (ncid) => {
191
217
  const unlimdimidPtr = module._malloc(4);
192
218
  const result = nc_inq_unlimdim_wrapper(ncid, unlimdimidPtr);
193
- const unlimdimid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(unlimdimidPtr, 'i32') : undefined;
219
+ const unlimdimid = result === NC_CONSTANTS.NC_NOERR
220
+ ? module.getValue(unlimdimidPtr, "i32")
221
+ : undefined;
194
222
  module._free(unlimdimidPtr);
195
223
  return { result, unlimdimid };
196
224
  },
@@ -200,8 +228,8 @@ export class WasmModuleLoader {
200
228
  const result = nc_inq_dimids_wrapper(ncid, ndimsPtr, dimidsPtr, include_parents);
201
229
  let ndims, dimids;
202
230
  if (result === NC_CONSTANTS.NC_NOERR) {
203
- ndims = module.getValue(ndimsPtr, 'i32');
204
- dimids = Int32Array.from({ length: ndims }, (_, i) => module.getValue(dimidsPtr + (i * 4), 'i32'));
231
+ ndims = module.getValue(ndimsPtr, "i32");
232
+ dimids = Int32Array.from({ length: ndims }, (_, i) => module.getValue(dimidsPtr + i * 4, "i32"));
205
233
  }
206
234
  module._free(ndimsPtr);
207
235
  module._free(dimidsPtr);
@@ -216,7 +244,7 @@ export class WasmModuleLoader {
216
244
  let name, len;
217
245
  if (result === NC_CONSTANTS.NC_NOERR) {
218
246
  name = module.UTF8ToString(namePtr);
219
- len = module.getValue(lenPtr, 'i32') >>> 0;
247
+ len = module.getValue(lenPtr, "i32") >>> 0;
220
248
  }
221
249
  module._free(namePtr);
222
250
  module._free(lenPtr);
@@ -225,7 +253,9 @@ export class WasmModuleLoader {
225
253
  nc_inq_dimid: (ncid, name) => {
226
254
  const dimidPtr = module._malloc(4);
227
255
  const result = nc_inq_dimid_wrapper(ncid, name, dimidPtr);
228
- const dimid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(dimidPtr, 'i32') : undefined;
256
+ const dimid = result === NC_CONSTANTS.NC_NOERR
257
+ ? module.getValue(dimidPtr, "i32")
258
+ : undefined;
229
259
  module._free(dimidPtr);
230
260
  return { result, dimid };
231
261
  },
@@ -236,7 +266,7 @@ export class WasmModuleLoader {
236
266
  const result = nc_inq_dimlen_wrapper(ncid, dimid, lenPtr);
237
267
  let len;
238
268
  if (result === NC_CONSTANTS.NC_NOERR) {
239
- len = module.getValue(lenPtr, 'i32') >>> 0;
269
+ len = module.getValue(lenPtr, "i32") >>> 0;
240
270
  }
241
271
  module._free(lenPtr);
242
272
  return { result, len };
@@ -245,7 +275,9 @@ export class WasmModuleLoader {
245
275
  const namePtr = module._malloc(NC_MAX_NAME + 1);
246
276
  module.HEAPU8.fill(0, namePtr, namePtr + NC_MAX_NAME + 1);
247
277
  const result = nc_inq_dimname_wrapper(ncid, dimid, namePtr);
248
- const name = result === NC_CONSTANTS.NC_NOERR ? module.UTF8ToString(namePtr) : undefined;
278
+ const name = result === NC_CONSTANTS.NC_NOERR
279
+ ? module.UTF8ToString(namePtr)
280
+ : undefined;
249
281
  module._free(namePtr);
250
282
  return { result, name };
251
283
  },
@@ -253,7 +285,9 @@ export class WasmModuleLoader {
253
285
  nc_inq_nvars: (ncid) => {
254
286
  const nvarsPtr = module._malloc(4);
255
287
  const result = nc_inq_nvars_wrapper(ncid, nvarsPtr);
256
- const nvars = result === NC_CONSTANTS.NC_NOERR ? module.getValue(nvarsPtr, 'i32') : undefined;
288
+ const nvars = result === NC_CONSTANTS.NC_NOERR
289
+ ? module.getValue(nvarsPtr, "i32")
290
+ : undefined;
257
291
  module._free(nvarsPtr);
258
292
  return { result, nvars };
259
293
  },
@@ -263,8 +297,8 @@ export class WasmModuleLoader {
263
297
  const result = nc_inq_varids_wrapper(ncid, nvarsPtr, varidsPtr);
264
298
  let nvars, varids;
265
299
  if (result === NC_CONSTANTS.NC_NOERR) {
266
- nvars = module.getValue(nvarsPtr, 'i32');
267
- varids = Int32Array.from({ length: nvars }, (_, i) => module.getValue(varidsPtr + (i * 4), 'i32'));
300
+ nvars = module.getValue(nvarsPtr, "i32");
301
+ varids = Int32Array.from({ length: nvars }, (_, i) => module.getValue(varidsPtr + i * 4, "i32"));
268
302
  }
269
303
  module._free(nvarsPtr);
270
304
  module._free(varidsPtr);
@@ -273,7 +307,9 @@ export class WasmModuleLoader {
273
307
  nc_inq_varid: (ncid, name) => {
274
308
  const varidPtr = module._malloc(4);
275
309
  const result = nc_inq_varid_wrapper(ncid, name, varidPtr);
276
- const varid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(varidPtr, 'i32') : undefined;
310
+ const varid = result === NC_CONSTANTS.NC_NOERR
311
+ ? module.getValue(varidPtr, "i32")
312
+ : undefined;
277
313
  module._free(varidPtr);
278
314
  return { result, varid };
279
315
  },
@@ -287,10 +323,10 @@ export class WasmModuleLoader {
287
323
  let name, type, ndims, dimids, natts;
288
324
  if (result === NC_CONSTANTS.NC_NOERR) {
289
325
  name = module.UTF8ToString(namePtr);
290
- type = module.getValue(typePtr, 'i32');
291
- ndims = module.getValue(ndimsPtr, 'i32');
292
- natts = module.getValue(nattsPtr, 'i32');
293
- dimids = Int32Array.from({ length: ndims }, (_, i) => module.getValue(dimidsPtr + (i * 4), 'i32'));
326
+ type = module.getValue(typePtr, "i32");
327
+ ndims = module.getValue(ndimsPtr, "i32");
328
+ natts = module.getValue(nattsPtr, "i32");
329
+ dimids = Int32Array.from({ length: ndims }, (_, i) => module.getValue(dimidsPtr + i * 4, "i32"));
294
330
  }
295
331
  module._free(namePtr);
296
332
  module._free(typePtr);
@@ -302,21 +338,27 @@ export class WasmModuleLoader {
302
338
  nc_inq_varname: (ncid, varid) => {
303
339
  const namePtr = module._malloc(NC_MAX_NAME + 1);
304
340
  const result = nc_inq_varname_wrapper(ncid, varid, namePtr);
305
- const name = result === NC_CONSTANTS.NC_NOERR ? module.UTF8ToString(namePtr) : undefined;
341
+ const name = result === NC_CONSTANTS.NC_NOERR
342
+ ? module.UTF8ToString(namePtr)
343
+ : undefined;
306
344
  module._free(namePtr);
307
345
  return { result, name };
308
346
  },
309
347
  nc_inq_vartype: (ncid, varid) => {
310
348
  const typePtr = module._malloc(4);
311
349
  const result = nc_inq_vartype_wrapper(ncid, varid, typePtr);
312
- const type = result === NC_CONSTANTS.NC_NOERR ? module.getValue(typePtr, 'i32') : undefined;
350
+ const type = result === NC_CONSTANTS.NC_NOERR
351
+ ? module.getValue(typePtr, "i32")
352
+ : undefined;
313
353
  module._free(typePtr);
314
354
  return { result, type };
315
355
  },
316
356
  nc_inq_varndims: (ncid, varid) => {
317
357
  const ndimsPtr = module._malloc(4);
318
358
  const result = nc_inq_varndims_wrapper(ncid, varid, ndimsPtr);
319
- const ndims = result === NC_CONSTANTS.NC_NOERR ? module.getValue(ndimsPtr, 'i32') : undefined;
359
+ const ndims = result === NC_CONSTANTS.NC_NOERR
360
+ ? module.getValue(ndimsPtr, "i32")
361
+ : undefined;
320
362
  module._free(ndimsPtr);
321
363
  return { result, ndims };
322
364
  },
@@ -340,7 +382,9 @@ export class WasmModuleLoader {
340
382
  nc_inq_varnatts: (ncid, varid) => {
341
383
  const nattsPtr = module._malloc(4);
342
384
  const result = nc_inq_varnatts_wrapper(ncid, varid, nattsPtr);
343
- const natts = result === NC_CONSTANTS.NC_NOERR ? module.getValue(nattsPtr, 'i32') : undefined;
385
+ const natts = result === NC_CONSTANTS.NC_NOERR
386
+ ? module.getValue(nattsPtr, "i32")
387
+ : undefined;
344
388
  module._free(nattsPtr);
345
389
  return { result, natts };
346
390
  },
@@ -350,19 +394,19 @@ export class WasmModuleLoader {
350
394
  const result = nc_inq_var_chunking_wrapper(ncid, varid, chunkingPtr, chunkSizesPtr);
351
395
  let chunking, chunkSizes;
352
396
  if (result === NC_CONSTANTS.NC_NOERR) {
353
- chunking = module.getValue(chunkingPtr, 'i32');
397
+ chunking = module.getValue(chunkingPtr, "i32");
354
398
  // First, get the number of dimensions for this variable
355
399
  const ndimsPtr = module._malloc(4);
356
400
  const inqResult = nc_inq_varndims_wrapper(ncid, varid, ndimsPtr);
357
401
  let ndims = NC_MAX_DIMS; // default fallback
358
402
  if (inqResult === NC_CONSTANTS.NC_NOERR) {
359
- ndims = module.getValue(ndimsPtr, 'i32');
403
+ ndims = module.getValue(ndimsPtr, "i32");
360
404
  }
361
405
  module._free(ndimsPtr);
362
406
  // Only read the actual number of dimensions
363
407
  chunkSizes = new Array(ndims);
364
408
  for (let i = 0; i < ndims; i++) {
365
- chunkSizes[i] = module.getValue(chunkSizesPtr + i * 4, 'i32');
409
+ chunkSizes[i] = module.getValue(chunkSizesPtr + i * 4, "i32");
366
410
  }
367
411
  }
368
412
  module._free(chunkingPtr);
@@ -373,7 +417,9 @@ export class WasmModuleLoader {
373
417
  nc_inq_natts: (ncid) => {
374
418
  const nattsPtr = module._malloc(4);
375
419
  const result = nc_inq_natts_wrapper(ncid, nattsPtr);
376
- const natts = result === NC_CONSTANTS.NC_NOERR ? module.getValue(nattsPtr, 'i32') : undefined;
420
+ const natts = result === NC_CONSTANTS.NC_NOERR
421
+ ? module.getValue(nattsPtr, "i32")
422
+ : undefined;
377
423
  module._free(nattsPtr);
378
424
  return { result, natts };
379
425
  },
@@ -383,8 +429,8 @@ export class WasmModuleLoader {
383
429
  const result = nc_inq_att_wrapper(ncid, varid, name, typePtr, lenPtr);
384
430
  let type, len;
385
431
  if (result === NC_CONSTANTS.NC_NOERR) {
386
- type = module.getValue(typePtr, 'i32');
387
- len = module.getValue(lenPtr, 'i32');
432
+ type = module.getValue(typePtr, "i32");
433
+ len = module.getValue(lenPtr, "i32");
388
434
  }
389
435
  module._free(typePtr);
390
436
  module._free(lenPtr);
@@ -393,28 +439,36 @@ export class WasmModuleLoader {
393
439
  nc_inq_attid: (ncid, varid, name) => {
394
440
  const attnumPtr = module._malloc(4);
395
441
  const result = nc_inq_attid_wrapper(ncid, varid, name, attnumPtr);
396
- const attnum = result === NC_CONSTANTS.NC_NOERR ? module.getValue(attnumPtr, 'i32') : undefined;
442
+ const attnum = result === NC_CONSTANTS.NC_NOERR
443
+ ? module.getValue(attnumPtr, "i32")
444
+ : undefined;
397
445
  module._free(attnumPtr);
398
446
  return { result, attnum };
399
447
  },
400
448
  nc_inq_attname: (ncid, varid, attnum) => {
401
449
  const namePtr = module._malloc(NC_MAX_NAME + 1);
402
450
  const result = nc_inq_attname_wrapper(ncid, varid, attnum, namePtr);
403
- const name = result === NC_CONSTANTS.NC_NOERR ? module.UTF8ToString(namePtr) : undefined;
451
+ const name = result === NC_CONSTANTS.NC_NOERR
452
+ ? module.UTF8ToString(namePtr)
453
+ : undefined;
404
454
  module._free(namePtr);
405
455
  return { result, name };
406
456
  },
407
457
  nc_inq_atttype: (ncid, varid, name) => {
408
458
  const typePtr = module._malloc(4);
409
459
  const result = nc_inq_atttype_wrapper(ncid, varid, name, typePtr);
410
- const type = result === NC_CONSTANTS.NC_NOERR ? module.getValue(typePtr, 'i32') : undefined;
460
+ const type = result === NC_CONSTANTS.NC_NOERR
461
+ ? module.getValue(typePtr, "i32")
462
+ : undefined;
411
463
  module._free(typePtr);
412
464
  return { result, type };
413
465
  },
414
466
  nc_inq_attlen: (ncid, varid, name) => {
415
467
  const lenPtr = module._malloc(8);
416
468
  const result = nc_inq_attlen_wrapper(ncid, varid, name, lenPtr);
417
- const len = result === NC_CONSTANTS.NC_NOERR ? module.getValue(lenPtr, 'i64') : undefined;
469
+ const len = result === NC_CONSTANTS.NC_NOERR
470
+ ? Number(module.getValue(lenPtr, "i64"))
471
+ : undefined;
418
472
  module._free(lenPtr);
419
473
  return { result, len };
420
474
  },
@@ -422,7 +476,7 @@ export class WasmModuleLoader {
422
476
  nc_get_att_text: (ncid, varid, name, length) => {
423
477
  const dataPtr = module._malloc(length + 1);
424
478
  const result = nc_get_att_text_wrapper(ncid, varid, name, dataPtr);
425
- module.setValue(dataPtr + length, 0, 'i8'); // Add null terminator so it doesn't read too far
479
+ module.setValue(dataPtr + length, 0, "i8"); // Add null terminator so it doesn't read too far
426
480
  const data = result === NC_CONSTANTS.NC_NOERR
427
481
  ? module.UTF8ToString(dataPtr)
428
482
  : undefined;
@@ -433,7 +487,7 @@ export class WasmModuleLoader {
433
487
  const dataPtr = module._malloc(length * 2);
434
488
  const result = nc_get_att_short_wrapper(ncid, varid, name, dataPtr);
435
489
  const data = result === NC_CONSTANTS.NC_NOERR
436
- ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 2, 'i16'))
490
+ ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 2, "i16"))
437
491
  : undefined;
438
492
  module._free(dataPtr);
439
493
  return { result, data };
@@ -442,7 +496,7 @@ export class WasmModuleLoader {
442
496
  const dataPtr = module._malloc(length * 4);
443
497
  const result = nc_get_att_int_wrapper(ncid, varid, name, dataPtr);
444
498
  const data = result === NC_CONSTANTS.NC_NOERR
445
- ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 4, 'i32'))
499
+ ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 4, "i32"))
446
500
  : undefined;
447
501
  module._free(dataPtr);
448
502
  return { result, data };
@@ -451,7 +505,7 @@ export class WasmModuleLoader {
451
505
  const dataPtr = module._malloc(length * 4);
452
506
  const result = nc_get_att_float_wrapper(ncid, varid, name, dataPtr);
453
507
  const data = result === NC_CONSTANTS.NC_NOERR
454
- ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 4, 'float'))
508
+ ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 4, "float"))
455
509
  : undefined;
456
510
  module._free(dataPtr);
457
511
  return { result, data };
@@ -460,7 +514,7 @@ export class WasmModuleLoader {
460
514
  const dataPtr = module._malloc(length * 8);
461
515
  const result = nc_get_att_double_wrapper(ncid, varid, name, dataPtr);
462
516
  const data = result === NC_CONSTANTS.NC_NOERR
463
- ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 8, 'double'))
517
+ ? Array.from({ length }, (_, i) => module.getValue(dataPtr + i * 8, "double"))
464
518
  : undefined;
465
519
  module._free(dataPtr);
466
520
  return { result, data };
@@ -469,7 +523,7 @@ export class WasmModuleLoader {
469
523
  const dataPtr = module._malloc(length * 8);
470
524
  const result = nc_get_att_longlong_wrapper(ncid, varid, name, dataPtr);
471
525
  const data = result === NC_CONSTANTS.NC_NOERR
472
- ? Array.from({ length }, (_, i) => BigInt(module.getValue(dataPtr + i * 8, 'i64')))
526
+ ? Array.from({ length }, (_, i) => BigInt(module.getValue(dataPtr + i * 8, "i64")))
473
527
  : undefined;
474
528
  module._free(dataPtr);
475
529
  return { result, data };
@@ -480,8 +534,8 @@ export class WasmModuleLoader {
480
534
  const dataPtr = module._malloc(totalLength * 2);
481
535
  const startPtr = module._malloc(start.length * 4);
482
536
  const countPtr = module._malloc(count.length * 4);
483
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
484
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
537
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
538
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
485
539
  const result = nc_get_vara_short_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
486
540
  const data = result === NC_CONSTANTS.NC_NOERR
487
541
  ? new Int16Array(module.HEAP16.buffer, dataPtr, totalLength).slice()
@@ -496,8 +550,8 @@ export class WasmModuleLoader {
496
550
  const dataPtr = module._malloc(totalLength * 4);
497
551
  const startPtr = module._malloc(start.length * 4);
498
552
  const countPtr = module._malloc(count.length * 4);
499
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
500
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
553
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
554
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
501
555
  const result = nc_get_vara_int_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
502
556
  const data = result === NC_CONSTANTS.NC_NOERR
503
557
  ? new Int32Array(module.HEAP32.buffer, dataPtr, totalLength).slice()
@@ -512,8 +566,8 @@ export class WasmModuleLoader {
512
566
  const dataPtr = module._malloc(totalLength * 4);
513
567
  const startPtr = module._malloc(start.length * 4);
514
568
  const countPtr = module._malloc(count.length * 4);
515
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
516
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
569
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
570
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
517
571
  const result = nc_get_vara_float_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
518
572
  const data = result === NC_CONSTANTS.NC_NOERR
519
573
  ? new Float32Array(module.HEAPF32.buffer, dataPtr, totalLength).slice()
@@ -528,8 +582,8 @@ export class WasmModuleLoader {
528
582
  const dataPtr = module._malloc(totalLength * 8);
529
583
  const startPtr = module._malloc(start.length * 4);
530
584
  const countPtr = module._malloc(count.length * 4);
531
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
532
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
585
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
586
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
533
587
  const result = nc_get_vara_double_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
534
588
  const data = result === NC_CONSTANTS.NC_NOERR
535
589
  ? new Float64Array(module.HEAPF64.buffer, dataPtr, totalLength).slice()
@@ -544,8 +598,8 @@ export class WasmModuleLoader {
544
598
  const dataPtr = module._malloc(totalLength * 8);
545
599
  const startPtr = module._malloc(start.length * 4);
546
600
  const countPtr = module._malloc(count.length * 4);
547
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
548
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
601
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
602
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
549
603
  const result = nc_get_vara_longlong_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
550
604
  const data = result === NC_CONSTANTS.NC_NOERR
551
605
  ? new BigInt64Array(module.HEAP64.buffer, dataPtr, totalLength).slice()
@@ -560,8 +614,8 @@ export class WasmModuleLoader {
560
614
  const dataPtr = module._malloc(totalLength * 1);
561
615
  const startPtr = module._malloc(start.length * 4);
562
616
  const countPtr = module._malloc(count.length * 4);
563
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
564
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
617
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
618
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
565
619
  const result = nc_get_vara_schar_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
566
620
  const data = result === NC_CONSTANTS.NC_NOERR
567
621
  ? new Int8Array(module.HEAP8.buffer, dataPtr, totalLength).slice()
@@ -576,8 +630,8 @@ export class WasmModuleLoader {
576
630
  const dataPtr = module._malloc(totalLength * 1);
577
631
  const startPtr = module._malloc(start.length * 4);
578
632
  const countPtr = module._malloc(count.length * 4);
579
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
580
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
633
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
634
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
581
635
  const result = nc_get_vara_uchar_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
582
636
  const data = result === NC_CONSTANTS.NC_NOERR
583
637
  ? new Uint8Array(module.HEAPU8.buffer, dataPtr, totalLength).slice()
@@ -592,8 +646,8 @@ export class WasmModuleLoader {
592
646
  const dataPtr = module._malloc(totalLength * 2);
593
647
  const startPtr = module._malloc(start.length * 4);
594
648
  const countPtr = module._malloc(count.length * 4);
595
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
596
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
649
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
650
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
597
651
  const result = nc_get_vara_ushort_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
598
652
  const data = result === NC_CONSTANTS.NC_NOERR
599
653
  ? new Uint16Array(module.HEAPU16.buffer, dataPtr, totalLength).slice()
@@ -608,8 +662,8 @@ export class WasmModuleLoader {
608
662
  const dataPtr = module._malloc(totalLength * 4);
609
663
  const startPtr = module._malloc(start.length * 4);
610
664
  const countPtr = module._malloc(count.length * 4);
611
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
612
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
665
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
666
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
613
667
  const result = nc_get_vara_uint_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
614
668
  const data = result === NC_CONSTANTS.NC_NOERR
615
669
  ? new Uint32Array(module.HEAPU32.buffer, dataPtr, totalLength).slice()
@@ -624,8 +678,8 @@ export class WasmModuleLoader {
624
678
  const dataPtr = module._malloc(totalLength * 8);
625
679
  const startPtr = module._malloc(start.length * 4);
626
680
  const countPtr = module._malloc(count.length * 4);
627
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
628
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
681
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
682
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
629
683
  const result = nc_get_vara_ulonglong_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
630
684
  const data = result === NC_CONSTANTS.NC_NOERR
631
685
  ? new BigUint64Array(module.HEAP64.buffer, dataPtr, totalLength).slice()
@@ -640,18 +694,23 @@ export class WasmModuleLoader {
640
694
  const dataPtr = module._malloc(totalLength * 4);
641
695
  const startPtr = module._malloc(start.length * 4);
642
696
  const countPtr = module._malloc(count.length * 4);
643
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
644
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
697
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
698
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
645
699
  const result = nc_get_vara_string_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
646
700
  let data;
647
701
  if (result === NC_CONSTANTS.NC_NOERR) {
648
702
  data = [];
649
703
  for (let i = 0; i < totalLength; i++) {
650
- const strPtr = module.getValue(dataPtr + i * 4, '*');
704
+ const strPtr = module.getValue(dataPtr + i * 4, "*");
651
705
  data.push(module.UTF8ToString(strPtr));
652
706
  }
707
+ // free the individual strings allocated by NetCDF-C before
708
+ // freeing the pointer array. nc_free_string_wrapper handles both.
709
+ nc_free_string_wrapper(totalLength, dataPtr);
710
+ }
711
+ else {
712
+ module._free(dataPtr);
653
713
  }
654
- module._free(dataPtr);
655
714
  module._free(startPtr);
656
715
  module._free(countPtr);
657
716
  return { result, data };
@@ -661,7 +720,11 @@ export class WasmModuleLoader {
661
720
  const dataPtr = module._malloc(length);
662
721
  const result = nc_get_var_text_wrapper(ncid, varid, dataPtr);
663
722
  const data = result === NC_CONSTANTS.NC_NOERR
664
- ? [new TextDecoder().decode(module.HEAPU8.subarray(dataPtr, dataPtr + length)).replace(/\0/g, '')]
723
+ ? [
724
+ new TextDecoder()
725
+ .decode(module.HEAPU8.subarray(dataPtr, dataPtr + length))
726
+ .replace(/\0/g, ""),
727
+ ]
665
728
  : undefined;
666
729
  module._free(dataPtr);
667
730
  return { result, data };
@@ -765,17 +828,22 @@ export class WasmModuleLoader {
765
828
  if (result === NC_CONSTANTS.NC_NOERR) {
766
829
  data = [];
767
830
  for (let i = 0; i < length; i++) {
768
- const strPtr = module.getValue(dataPtr + i * 4, '*');
831
+ const strPtr = module.getValue(dataPtr + i * 4, "*");
769
832
  data.push(module.UTF8ToString(strPtr));
770
833
  }
834
+ // free the individual strings allocated by NetCDF-C before
835
+ // freeing the pointer array. nc_free_string_wrapper handles both.
836
+ nc_free_string_wrapper(length, dataPtr);
837
+ }
838
+ else {
839
+ module._free(dataPtr);
771
840
  }
772
- module._free(dataPtr);
773
841
  return { result, data };
774
842
  },
775
843
  nc_def_dim: (ncid, name, len) => {
776
844
  const dimidPtr = module._malloc(4);
777
845
  const result = nc_def_dim_wrapper(ncid, name, len, dimidPtr);
778
- const dimid = module.getValue(dimidPtr, 'i32');
846
+ const dimid = module.getValue(dimidPtr, "i32");
779
847
  module._free(dimidPtr);
780
848
  return { result, dimid };
781
849
  },
@@ -783,10 +851,10 @@ export class WasmModuleLoader {
783
851
  const varidPtr = module._malloc(4);
784
852
  const dimidsPtr = module._malloc(dimids.length * 4);
785
853
  for (let i = 0; i < dimids.length; i++) {
786
- module.setValue(dimidsPtr + i * 4, dimids[i], 'i32');
854
+ module.setValue(dimidsPtr + i * 4, dimids[i], "i32");
787
855
  }
788
856
  const result = nc_def_var_wrapper(ncid, name, xtype, ndims, dimidsPtr, varidPtr);
789
- const varid = module.getValue(varidPtr, 'i32');
857
+ const varid = module.getValue(varidPtr, "i32");
790
858
  module._free(varidPtr);
791
859
  module._free(dimidsPtr);
792
860
  return { result, varid };
@@ -818,8 +886,8 @@ export class WasmModuleLoader {
818
886
  const result = nc_inq_grps_wrapper(ncid, numgrpsPtr, grpidsPtr);
819
887
  let numgrps, grpids;
820
888
  if (result === NC_CONSTANTS.NC_NOERR) {
821
- numgrps = module.getValue(numgrpsPtr, 'i32');
822
- grpids = Int32Array.from({ length: numgrps }, (_, i) => module.getValue(grpidsPtr + (i * 4), 'i32'));
889
+ numgrps = module.getValue(numgrpsPtr, "i32");
890
+ grpids = Int32Array.from({ length: numgrps }, (_, i) => module.getValue(grpidsPtr + i * 4, "i32"));
823
891
  }
824
892
  module._free(numgrpsPtr);
825
893
  module._free(grpidsPtr);
@@ -828,28 +896,36 @@ export class WasmModuleLoader {
828
896
  nc_inq_grp_ncid: (ncid, grp_name) => {
829
897
  const grp_ncidPtr = module._malloc(4);
830
898
  const result = nc_inq_grp_ncid_wrapper(ncid, grp_name, grp_ncidPtr);
831
- const grp_ncid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(grp_ncidPtr, 'i32') : undefined;
899
+ const grp_ncid = result === NC_CONSTANTS.NC_NOERR
900
+ ? module.getValue(grp_ncidPtr, "i32")
901
+ : undefined;
832
902
  module._free(grp_ncidPtr);
833
903
  return { result, grp_ncid };
834
904
  },
835
905
  nc_inq_grpname: (ncid) => {
836
906
  const namePtr = module._malloc(NC_MAX_NAME + 1);
837
907
  const result = nc_inq_grpname_wrapper(ncid, namePtr);
838
- const name = result === NC_CONSTANTS.NC_NOERR ? module.UTF8ToString(namePtr) : undefined;
908
+ const name = result === NC_CONSTANTS.NC_NOERR
909
+ ? module.UTF8ToString(namePtr)
910
+ : undefined;
839
911
  module._free(namePtr);
840
912
  return { result, name };
841
913
  },
842
914
  nc_inq_grp_parent: (ncid) => {
843
915
  const parent_ncidPtr = module._malloc(4);
844
916
  const result = nc_inq_grp_parent_wrapper(ncid, parent_ncidPtr);
845
- const parent_ncid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(parent_ncidPtr, 'i32') : undefined;
917
+ const parent_ncid = result === NC_CONSTANTS.NC_NOERR
918
+ ? module.getValue(parent_ncidPtr, "i32")
919
+ : undefined;
846
920
  module._free(parent_ncidPtr);
847
921
  return { result, parent_ncid };
848
922
  },
849
923
  nc_inq_grp_full_ncid: (ncid, full_name) => {
850
924
  const grp_ncidPtr = module._malloc(4);
851
925
  const result = nc_inq_grp_full_ncid_wrapper(ncid, full_name, grp_ncidPtr);
852
- const grp_ncid = result === NC_CONSTANTS.NC_NOERR ? module.getValue(grp_ncidPtr, 'i32') : undefined;
926
+ const grp_ncid = result === NC_CONSTANTS.NC_NOERR
927
+ ? module.getValue(grp_ncidPtr, "i32")
928
+ : undefined;
853
929
  module._free(grp_ncidPtr);
854
930
  return { result, grp_ncid };
855
931
  },
@@ -858,7 +934,9 @@ export class WasmModuleLoader {
858
934
  const lenpPtr = module._malloc(8); // size_t
859
935
  const namePtr = module._malloc(maxLen);
860
936
  const result = nc_inq_grpname_full_wrapper(ncid, lenpPtr, namePtr);
861
- const full_name = result === NC_CONSTANTS.NC_NOERR ? module.UTF8ToString(namePtr) : undefined;
937
+ const full_name = result === NC_CONSTANTS.NC_NOERR
938
+ ? module.UTF8ToString(namePtr)
939
+ : undefined;
862
940
  module._free(lenpPtr);
863
941
  module._free(namePtr);
864
942
  return { result, full_name };
@@ -866,7 +944,9 @@ export class WasmModuleLoader {
866
944
  nc_inq_grpname_len: (ncid) => {
867
945
  const lenpPtr = module._malloc(8); // size_t
868
946
  const result = nc_inq_grpname_len_wrapper(ncid, lenpPtr);
869
- const lenp = result === NC_CONSTANTS.NC_NOERR ? module.getValue(lenpPtr, 'i64') : undefined;
947
+ const lenp = result === NC_CONSTANTS.NC_NOERR
948
+ ? Number(module.getValue(lenpPtr, "i64"))
949
+ : undefined;
870
950
  module._free(lenpPtr);
871
951
  return { result, lenp };
872
952
  },
@@ -880,7 +960,7 @@ export class WasmModuleLoader {
880
960
  }
881
961
  const data = [];
882
962
  for (let i = 0; i < length; i++) {
883
- const strPtr = module.getValue(ptrArray + i * 4, '*');
963
+ const strPtr = module.getValue(ptrArray + i * 4, "*");
884
964
  data.push(module.UTF8ToString(strPtr));
885
965
  }
886
966
  // free strings allocated by netcdf
@@ -948,10 +1028,10 @@ export class WasmModuleLoader {
948
1028
  let ntypes;
949
1029
  let typeids;
950
1030
  if (result === NC_CONSTANTS.NC_NOERR) {
951
- ntypes = module.getValue(ntypesPtr, 'i32');
1031
+ ntypes = module.getValue(ntypesPtr, "i32");
952
1032
  typeids = [];
953
1033
  for (let i = 0; i < ntypes; i++) {
954
- typeids.push(module.getValue(typeidsPtr + i * 4, 'i32'));
1034
+ typeids.push(module.getValue(typeidsPtr + i * 4, "i32"));
955
1035
  }
956
1036
  }
957
1037
  module._free(ntypesPtr);
@@ -966,7 +1046,7 @@ export class WasmModuleLoader {
966
1046
  let size;
967
1047
  if (result === NC_CONSTANTS.NC_NOERR) {
968
1048
  name = module.UTF8ToString(namePtr);
969
- size = Number(module.getValue(sizePtr, 'i64'));
1049
+ size = Number(module.getValue(sizePtr, "i64"));
970
1050
  }
971
1051
  module._free(namePtr);
972
1052
  module._free(sizePtr);
@@ -986,10 +1066,10 @@ export class WasmModuleLoader {
986
1066
  let typeClass;
987
1067
  if (result === NC_CONSTANTS.NC_NOERR) {
988
1068
  name = module.UTF8ToString(namePtr);
989
- size = Number(module.getValue(sizePtr, 'i64'));
990
- baseType = module.getValue(baseTypePtr, 'i32');
991
- nfields = Number(module.getValue(nfieldsPtr, 'i64'));
992
- typeClass = module.getValue(classPtr, 'i32');
1069
+ size = Number(module.getValue(sizePtr, "i64"));
1070
+ baseType = module.getValue(baseTypePtr, "i32");
1071
+ nfields = Number(module.getValue(nfieldsPtr, "i64"));
1072
+ typeClass = module.getValue(classPtr, "i32");
993
1073
  }
994
1074
  module._free(namePtr);
995
1075
  module._free(sizePtr);
@@ -1003,21 +1083,21 @@ export class WasmModuleLoader {
1003
1083
  const result = nc_def_enum_wrapper(ncid, baseTypeId, name, typeidPtr);
1004
1084
  let typeid;
1005
1085
  if (result === NC_CONSTANTS.NC_NOERR) {
1006
- typeid = module.getValue(typeidPtr, 'i32');
1086
+ typeid = module.getValue(typeidPtr, "i32");
1007
1087
  }
1008
1088
  module._free(typeidPtr);
1009
1089
  return { result, typeid };
1010
1090
  },
1011
1091
  nc_insert_enum: (ncid, xtype, name, value) => {
1012
1092
  const valuePtr = module._malloc(8); // Always allocate 8 bytes (max needed)
1013
- if (typeof value === 'bigint') {
1093
+ if (typeof value === "bigint") {
1014
1094
  // Write bigint as 64-bit integer
1015
1095
  const i64Array = new BigInt64Array(module.HEAP8.buffer, valuePtr, 1);
1016
1096
  i64Array[0] = value;
1017
1097
  }
1018
1098
  else {
1019
1099
  // Write number as 32-bit integer (works for byte, short, int, uint)
1020
- module.setValue(valuePtr, value, 'i32');
1100
+ module.setValue(valuePtr, value, "i32");
1021
1101
  }
1022
1102
  const result = nc_insert_enum_wrapper(ncid, xtype, name, valuePtr);
1023
1103
  module._free(valuePtr);
@@ -1035,10 +1115,10 @@ export class WasmModuleLoader {
1035
1115
  let numMembers;
1036
1116
  if (result === NC_CONSTANTS.NC_NOERR) {
1037
1117
  name = module.UTF8ToString(namePtr);
1038
- baseType = module.getValue(baseTypePtr, 'i32');
1118
+ baseType = module.getValue(baseTypePtr, "i32");
1039
1119
  // Try reading as 32-bit size_t first
1040
- baseSize = Number(module.getValue(baseSizePtr, 'i32'));
1041
- numMembers = Number(module.getValue(numMembersPtr, 'i32'));
1120
+ baseSize = Number(module.getValue(baseSizePtr, "i32"));
1121
+ numMembers = Number(module.getValue(numMembersPtr, "i32"));
1042
1122
  }
1043
1123
  module._free(namePtr);
1044
1124
  module._free(baseTypePtr);
@@ -1057,31 +1137,31 @@ export class WasmModuleLoader {
1057
1137
  // Read value based on base type
1058
1138
  switch (baseType) {
1059
1139
  case NC_CONSTANTS.NC_BYTE:
1060
- value = module.getValue(valuePtr, 'i8');
1140
+ value = module.getValue(valuePtr, "i8");
1061
1141
  break;
1062
1142
  case NC_CONSTANTS.NC_UBYTE:
1063
- value = module.getValue(valuePtr, 'i8') & 0xFF;
1143
+ value = module.getValue(valuePtr, "i8") & 0xff;
1064
1144
  break;
1065
1145
  case NC_CONSTANTS.NC_SHORT:
1066
- value = module.getValue(valuePtr, 'i16');
1146
+ value = module.getValue(valuePtr, "i16");
1067
1147
  break;
1068
1148
  case NC_CONSTANTS.NC_USHORT:
1069
- value = module.getValue(valuePtr, 'i16') & 0xFFFF;
1149
+ value = module.getValue(valuePtr, "i16") & 0xffff;
1070
1150
  break;
1071
1151
  case NC_CONSTANTS.NC_INT:
1072
- value = module.getValue(valuePtr, 'i32');
1152
+ value = module.getValue(valuePtr, "i32");
1073
1153
  break;
1074
1154
  case NC_CONSTANTS.NC_UINT:
1075
- value = module.getValue(valuePtr, 'i32') >>> 0;
1155
+ value = module.getValue(valuePtr, "i32") >>> 0;
1076
1156
  break;
1077
1157
  case NC_CONSTANTS.NC_INT64:
1078
- value = module.getValue(valuePtr, 'i64');
1158
+ value = module.getValue(valuePtr, "i64");
1079
1159
  break;
1080
1160
  case NC_CONSTANTS.NC_UINT64:
1081
- value = module.getValue(valuePtr, 'i64');
1161
+ value = module.getValue(valuePtr, "i64");
1082
1162
  break;
1083
1163
  default:
1084
- value = module.getValue(valuePtr, 'i32');
1164
+ value = module.getValue(valuePtr, "i32");
1085
1165
  }
1086
1166
  }
1087
1167
  module._free(namePtr);
@@ -1090,7 +1170,7 @@ export class WasmModuleLoader {
1090
1170
  },
1091
1171
  nc_inq_enum_ident: (ncid, xtype, value) => {
1092
1172
  const identPtr = module._malloc(NC_CONSTANTS.NC_MAX_NAME + 1);
1093
- const numValue = typeof value === 'bigint' ? Number(value) : value;
1173
+ const numValue = typeof value === "bigint" ? Number(value) : value;
1094
1174
  const result = nc_inq_enum_ident_wrapper(ncid, xtype, numValue, identPtr);
1095
1175
  let identifier;
1096
1176
  if (result === NC_CONSTANTS.NC_NOERR) {
@@ -1142,8 +1222,8 @@ export class WasmModuleLoader {
1142
1222
  const dataPtr = module._malloc(totalLength * elementSize);
1143
1223
  const startPtr = module._malloc(start.length * 4);
1144
1224
  const countPtr = module._malloc(count.length * 4);
1145
- start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
1146
- count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
1225
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, "i32"));
1226
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, "i32"));
1147
1227
  const result = nc_get_vara_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
1148
1228
  let data;
1149
1229
  if (result === NC_CONSTANTS.NC_NOERR) {
@@ -1186,9 +1266,9 @@ export class WasmModuleLoader {
1186
1266
  const startPtr = module._malloc(start.length * 4);
1187
1267
  const countPtr = module._malloc(count.length * 4);
1188
1268
  const stridePtr = module._malloc(stride.length * 4);
1189
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1190
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1191
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1269
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1270
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1271
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1192
1272
  const result = nc_get_vars_schar_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1193
1273
  const data = result === NC_CONSTANTS.NC_NOERR
1194
1274
  ? new Int8Array(module.HEAP8.buffer, dataPtr, totalLength).slice()
@@ -1205,9 +1285,9 @@ export class WasmModuleLoader {
1205
1285
  const startPtr = module._malloc(start.length * 4);
1206
1286
  const countPtr = module._malloc(count.length * 4);
1207
1287
  const stridePtr = module._malloc(stride.length * 4);
1208
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1209
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1210
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1288
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1289
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1290
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1211
1291
  const result = nc_get_vars_uchar_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1212
1292
  const data = result === NC_CONSTANTS.NC_NOERR
1213
1293
  ? new Uint8Array(module.HEAPU8.buffer, dataPtr, totalLength).slice()
@@ -1224,9 +1304,9 @@ export class WasmModuleLoader {
1224
1304
  const startPtr = module._malloc(start.length * 4);
1225
1305
  const countPtr = module._malloc(count.length * 4);
1226
1306
  const stridePtr = module._malloc(stride.length * 4);
1227
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1228
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1229
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1307
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1308
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1309
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1230
1310
  const result = nc_get_vars_short_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1231
1311
  const data = result === NC_CONSTANTS.NC_NOERR
1232
1312
  ? new Int16Array(module.HEAP16.buffer, dataPtr, totalLength).slice()
@@ -1243,9 +1323,9 @@ export class WasmModuleLoader {
1243
1323
  const startPtr = module._malloc(start.length * 4);
1244
1324
  const countPtr = module._malloc(count.length * 4);
1245
1325
  const stridePtr = module._malloc(stride.length * 4);
1246
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1247
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1248
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1326
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1327
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1328
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1249
1329
  const result = nc_get_vars_ushort_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1250
1330
  const data = result === NC_CONSTANTS.NC_NOERR
1251
1331
  ? new Uint16Array(module.HEAPU16.buffer, dataPtr, totalLength).slice()
@@ -1262,9 +1342,9 @@ export class WasmModuleLoader {
1262
1342
  const startPtr = module._malloc(start.length * 4);
1263
1343
  const countPtr = module._malloc(count.length * 4);
1264
1344
  const stridePtr = module._malloc(stride.length * 4);
1265
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1266
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1267
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1345
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1346
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1347
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1268
1348
  const result = nc_get_vars_int_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1269
1349
  const data = result === NC_CONSTANTS.NC_NOERR
1270
1350
  ? new Int32Array(module.HEAP32.buffer, dataPtr, totalLength).slice()
@@ -1281,9 +1361,9 @@ export class WasmModuleLoader {
1281
1361
  const startPtr = module._malloc(start.length * 4);
1282
1362
  const countPtr = module._malloc(count.length * 4);
1283
1363
  const stridePtr = module._malloc(stride.length * 4);
1284
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1285
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1286
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1364
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1365
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1366
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1287
1367
  const result = nc_get_vars_uint_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1288
1368
  const data = result === NC_CONSTANTS.NC_NOERR
1289
1369
  ? new Uint32Array(module.HEAPU32.buffer, dataPtr, totalLength).slice()
@@ -1300,9 +1380,9 @@ export class WasmModuleLoader {
1300
1380
  const startPtr = module._malloc(start.length * 4);
1301
1381
  const countPtr = module._malloc(count.length * 4);
1302
1382
  const stridePtr = module._malloc(stride.length * 4);
1303
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1304
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1305
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1383
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1384
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1385
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1306
1386
  const result = nc_get_vars_float_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1307
1387
  const data = result === NC_CONSTANTS.NC_NOERR
1308
1388
  ? new Float32Array(module.HEAPF32.buffer, dataPtr, totalLength).slice()
@@ -1319,9 +1399,9 @@ export class WasmModuleLoader {
1319
1399
  const startPtr = module._malloc(start.length * 4);
1320
1400
  const countPtr = module._malloc(count.length * 4);
1321
1401
  const stridePtr = module._malloc(stride.length * 4);
1322
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1323
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1324
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1402
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1403
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1404
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1325
1405
  const result = nc_get_vars_double_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1326
1406
  const data = result === NC_CONSTANTS.NC_NOERR
1327
1407
  ? new Float64Array(module.HEAPF64.buffer, dataPtr, totalLength).slice()
@@ -1338,9 +1418,9 @@ export class WasmModuleLoader {
1338
1418
  const startPtr = module._malloc(start.length * 4);
1339
1419
  const countPtr = module._malloc(count.length * 4);
1340
1420
  const stridePtr = module._malloc(stride.length * 4);
1341
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1342
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1343
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1421
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1422
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1423
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1344
1424
  const result = nc_get_vars_longlong_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1345
1425
  const data = result === NC_CONSTANTS.NC_NOERR
1346
1426
  ? new BigInt64Array(module.HEAP64.buffer, dataPtr, totalLength).slice()
@@ -1357,9 +1437,9 @@ export class WasmModuleLoader {
1357
1437
  const startPtr = module._malloc(start.length * 4);
1358
1438
  const countPtr = module._malloc(count.length * 4);
1359
1439
  const stridePtr = module._malloc(stride.length * 4);
1360
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1361
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1362
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1440
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1441
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1442
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1363
1443
  const result = nc_get_vars_ulonglong_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1364
1444
  const data = result === NC_CONSTANTS.NC_NOERR
1365
1445
  ? new BigUint64Array(module.HEAPU64.buffer, dataPtr, totalLength).slice()
@@ -1378,15 +1458,15 @@ export class WasmModuleLoader {
1378
1458
  const startPtr = module._malloc(start.length * 4);
1379
1459
  const countPtr = module._malloc(count.length * 4);
1380
1460
  const stridePtr = module._malloc(stride.length * 4);
1381
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1382
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1383
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1461
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1462
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1463
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1384
1464
  const result = nc_get_vars_string_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1385
1465
  let data;
1386
1466
  if (result === NC_CONSTANTS.NC_NOERR) {
1387
1467
  data = [];
1388
1468
  for (let i = 0; i < totalLength; i++) {
1389
- const strPtr = module.getValue(dataPtr + i * 4, '*');
1469
+ const strPtr = module.getValue(dataPtr + i * 4, "*");
1390
1470
  data.push(module.UTF8ToString(strPtr));
1391
1471
  }
1392
1472
  // free the individual strings allocated by NetCDF-C before
@@ -1407,9 +1487,9 @@ export class WasmModuleLoader {
1407
1487
  const startPtr = module._malloc(start.length * 4);
1408
1488
  const countPtr = module._malloc(count.length * 4);
1409
1489
  const stridePtr = module._malloc(stride.length * 4);
1410
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1411
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1412
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1490
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1491
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1492
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1413
1493
  if (nctype === NC_CONSTANTS.NC_STRING) {
1414
1494
  // validate allocation size won't overflow WASM32 uint32.
1415
1495
  const dataPtr = module._malloc(safeByteLength(totalLength, 4));
@@ -1418,7 +1498,7 @@ export class WasmModuleLoader {
1418
1498
  if (result === NC_CONSTANTS.NC_NOERR) {
1419
1499
  data = [];
1420
1500
  for (let i = 0; i < totalLength; i++) {
1421
- const strPtr = module.getValue(dataPtr + i * 4, '*');
1501
+ const strPtr = module.getValue(dataPtr + i * 4, "*");
1422
1502
  data.push(module.UTF8ToString(strPtr));
1423
1503
  }
1424
1504
  // free the individual strings allocated by NetCDF-C before
@@ -1483,12 +1563,12 @@ export class WasmModuleLoader {
1483
1563
  const startPtr = module._malloc(start.length * 4);
1484
1564
  const countPtr = module._malloc(count.length * 4);
1485
1565
  const stridePtr = module._malloc(stride.length * 4);
1486
- start.forEach((v, i) => module.setValue(startPtr + i * 4, v, 'i32'));
1487
- count.forEach((v, i) => module.setValue(countPtr + i * 4, v, 'i32'));
1488
- stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, 'i32'));
1566
+ start.forEach((v, i) => module.setValue(startPtr + i * 4, v, "i32"));
1567
+ count.forEach((v, i) => module.setValue(countPtr + i * 4, v, "i32"));
1568
+ stride.forEach((v, i) => module.setValue(stridePtr + i * 4, v, "i32"));
1489
1569
  const result = nc_get_vars_text_wrapper(ncid, varid, startPtr, countPtr, stridePtr, dataPtr);
1490
1570
  const data = result === NC_CONSTANTS.NC_NOERR
1491
- ? Array.from(new TextDecoder().decode(module.HEAPU8.subarray(dataPtr, dataPtr + totalLength)), char => char === '\0' ? '' : char)
1571
+ ? Array.from(new TextDecoder().decode(module.HEAPU8.subarray(dataPtr, dataPtr + totalLength)), (char) => (char === "\0" ? "" : char))
1492
1572
  : undefined;
1493
1573
  module._free(dataPtr);
1494
1574
  module._free(startPtr);