@lynx-js/tasm 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
- # 0.0.25
3
+ # 0.0.26
4
4
  * fix `Module.__malloc` not found issue. #5150
5
5
 
6
6
  # 0.0.24
Binary file
Binary file
package/index.js CHANGED
@@ -101,8 +101,8 @@ function decode_napi(templateJS) {
101
101
  return JSON.parse(res.result);
102
102
  }
103
103
 
104
- function decode_wasm(buffer) {
105
- const Module = loadModule();
104
+ async function decode_wasm(buffer) {
105
+ const Module = await loadModule();
106
106
  // console.log(templateJs);
107
107
  // const uint8array = new Uint8Array(templateJs.size());
108
108
  // const res = m._decode(uint8array);
@@ -122,27 +122,6 @@ function decode_wasm(buffer) {
122
122
  return JSON.parse(res.result);
123
123
  }
124
124
 
125
- function decode_wasm(buffer) {
126
- const Module = loadModule();
127
- // console.log(templateJs);
128
- // const uint8array = new Uint8Array(templateJs.size());
129
- // const res = m._decode(uint8array);
130
- const byteArray = new Uint8Array(buffer);
131
- const byteArrayLength = byteArray.length;
132
- // Allocate memory in the Emscripten heap
133
- const byteArrayPtr = Module._malloc(byteArrayLength);
134
- // Copy the data to the Emscripten heap
135
- Module.HEAPU8.set(byteArray, byteArrayPtr);
136
- // Call the C++ function
137
- const res = Module._decode(byteArrayPtr, byteArrayLength);
138
- // Free the allocated memory
139
- Module._free(byteArrayPtr);
140
- if (res.status !== 0) {
141
- throw new Error(`decode error: ${res.result}`);
142
- }
143
- return res;
144
- }
145
-
146
125
  let encode = encode_napi;
147
126
  module.exports = {
148
127
  supportNapi,