m-bus-parser-wasm-pack 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,13 +6,13 @@ export function __wbg_set_wasm(val) {
|
|
|
6
6
|
|
|
7
7
|
let WASM_VECTOR_LEN = 0;
|
|
8
8
|
|
|
9
|
-
let
|
|
9
|
+
let cachedUint8ArrayMemory0 = null;
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
|
|
11
|
+
function getUint8ArrayMemory0() {
|
|
12
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return cachedUint8ArrayMemory0;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
@@ -37,7 +37,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
37
37
|
if (realloc === undefined) {
|
|
38
38
|
const buf = cachedTextEncoder.encode(arg);
|
|
39
39
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
40
|
-
|
|
40
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
41
41
|
WASM_VECTOR_LEN = buf.length;
|
|
42
42
|
return ptr;
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
45
45
|
let len = arg.length;
|
|
46
46
|
let ptr = malloc(len, 1) >>> 0;
|
|
47
47
|
|
|
48
|
-
const mem =
|
|
48
|
+
const mem = getUint8ArrayMemory0();
|
|
49
49
|
|
|
50
50
|
let offset = 0;
|
|
51
51
|
|
|
@@ -60,7 +60,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
60
60
|
arg = arg.slice(offset);
|
|
61
61
|
}
|
|
62
62
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
63
|
-
const view =
|
|
63
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
64
64
|
const ret = encodeString(arg, view);
|
|
65
65
|
|
|
66
66
|
offset += ret.written;
|
|
@@ -71,13 +71,13 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
71
71
|
return ptr;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
let
|
|
74
|
+
let cachedDataViewMemory0 = null;
|
|
75
75
|
|
|
76
|
-
function
|
|
77
|
-
if (
|
|
78
|
-
|
|
76
|
+
function getDataViewMemory0() {
|
|
77
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
78
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
79
79
|
}
|
|
80
|
-
return
|
|
80
|
+
return cachedDataViewMemory0;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
@@ -88,7 +88,7 @@ cachedTextDecoder.decode();
|
|
|
88
88
|
|
|
89
89
|
function getStringFromWasm0(ptr, len) {
|
|
90
90
|
ptr = ptr >>> 0;
|
|
91
|
-
return cachedTextDecoder.decode(
|
|
91
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* @param {string} data
|
|
@@ -105,8 +105,8 @@ export function m_bus_parse(data, format) {
|
|
|
105
105
|
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
106
|
const len1 = WASM_VECTOR_LEN;
|
|
107
107
|
wasm.m_bus_parse(retptr, ptr0, len0, ptr1, len1);
|
|
108
|
-
var r0 =
|
|
109
|
-
var r1 =
|
|
108
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
109
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
110
110
|
deferred3_0 = r0;
|
|
111
111
|
deferred3_1 = r1;
|
|
112
112
|
return getStringFromWasm0(r0, r1);
|
|
Binary file
|