m-bus-parser-wasm-pack 0.0.3 → 0.0.4

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.
@@ -1,3 +1,4 @@
1
+
1
2
  import * as wasm from "./m_bus_parser_wasm_pack_bg.wasm";
2
3
  import { __wbg_set_wasm } from "./m_bus_parser_wasm_pack_bg.js";
3
4
  __wbg_set_wasm(wasm);
@@ -6,13 +6,13 @@ export function __wbg_set_wasm(val) {
6
6
 
7
7
  let WASM_VECTOR_LEN = 0;
8
8
 
9
- let cachedUint8Memory0 = null;
9
+ let cachedUint8ArrayMemory0 = null;
10
10
 
11
- function getUint8Memory0() {
12
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
13
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
11
+ function getUint8ArrayMemory0() {
12
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
14
  }
15
- return cachedUint8Memory0;
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
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
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 = getUint8Memory0();
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 = getUint8Memory0().subarray(ptr + offset, ptr + len);
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 cachedInt32Memory0 = null;
74
+ let cachedDataViewMemory0 = null;
75
75
 
76
- function getInt32Memory0() {
77
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
78
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
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 cachedInt32Memory0;
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(getUint8Memory0().subarray(ptr, ptr + len));
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 = getInt32Memory0()[retptr / 4 + 0];
109
- var r1 = getInt32Memory0()[retptr / 4 + 1];
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
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Michael Aebli"
6
6
  ],
7
7
  "description": "A wasm-pack to use the library for parsing M-Bus frames",
8
- "version": "0.0.3",
8
+ "version": "0.0.4",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",