m-bus-parser-wasm-pack 0.0.1
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/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let WASM_VECTOR_LEN = 0;
|
|
8
|
+
|
|
9
|
+
let cachedUint8Memory0 = null;
|
|
10
|
+
|
|
11
|
+
function getUint8Memory0() {
|
|
12
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
13
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
+
}
|
|
15
|
+
return cachedUint8Memory0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
19
|
+
|
|
20
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
21
|
+
|
|
22
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
23
|
+
? function (arg, view) {
|
|
24
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
25
|
+
}
|
|
26
|
+
: function (arg, view) {
|
|
27
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
28
|
+
view.set(buf);
|
|
29
|
+
return {
|
|
30
|
+
read: arg.length,
|
|
31
|
+
written: buf.length
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
36
|
+
|
|
37
|
+
if (realloc === undefined) {
|
|
38
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
39
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
40
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
41
|
+
WASM_VECTOR_LEN = buf.length;
|
|
42
|
+
return ptr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let len = arg.length;
|
|
46
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
47
|
+
|
|
48
|
+
const mem = getUint8Memory0();
|
|
49
|
+
|
|
50
|
+
let offset = 0;
|
|
51
|
+
|
|
52
|
+
for (; offset < len; offset++) {
|
|
53
|
+
const code = arg.charCodeAt(offset);
|
|
54
|
+
if (code > 0x7F) break;
|
|
55
|
+
mem[ptr + offset] = code;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (offset !== len) {
|
|
59
|
+
if (offset !== 0) {
|
|
60
|
+
arg = arg.slice(offset);
|
|
61
|
+
}
|
|
62
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
63
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
64
|
+
const ret = encodeString(arg, view);
|
|
65
|
+
|
|
66
|
+
offset += ret.written;
|
|
67
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
WASM_VECTOR_LEN = offset;
|
|
71
|
+
return ptr;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let cachedInt32Memory0 = null;
|
|
75
|
+
|
|
76
|
+
function getInt32Memory0() {
|
|
77
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
78
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
79
|
+
}
|
|
80
|
+
return cachedInt32Memory0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
84
|
+
|
|
85
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
86
|
+
|
|
87
|
+
cachedTextDecoder.decode();
|
|
88
|
+
|
|
89
|
+
function getStringFromWasm0(ptr, len) {
|
|
90
|
+
ptr = ptr >>> 0;
|
|
91
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @param {string} s
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
export function m_bus_parse(s) {
|
|
98
|
+
let deferred2_0;
|
|
99
|
+
let deferred2_1;
|
|
100
|
+
try {
|
|
101
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
102
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
wasm.m_bus_parse(retptr, ptr0, len0);
|
|
105
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
106
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
107
|
+
deferred2_0 = r0;
|
|
108
|
+
deferred2_1 = r1;
|
|
109
|
+
return getStringFromWasm0(r0, r1);
|
|
110
|
+
} finally {
|
|
111
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
112
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "m-bus-parser-wasm-pack",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"Michael Aebli"
|
|
5
|
+
],
|
|
6
|
+
"description": "A wasm-pack to use the library for parsing M-Bus frames",
|
|
7
|
+
"version": "0.0.1",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/maebli/m-bus-parser"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"m_bus_parser_wasm_pack_bg.wasm",
|
|
15
|
+
"m_bus_parser_wasm_pack.js",
|
|
16
|
+
"m_bus_parser_wasm_pack_bg.js",
|
|
17
|
+
"m_bus_parser_wasm_pack.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"module": "m_bus_parser_wasm_pack.js",
|
|
20
|
+
"homepage": "https://maebli.github.io/",
|
|
21
|
+
"types": "m_bus_parser_wasm_pack.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./m_bus_parser_wasm_pack.js",
|
|
24
|
+
"./snippets/*"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"m-bus",
|
|
28
|
+
"parser",
|
|
29
|
+
"parse",
|
|
30
|
+
"wasm-pack"
|
|
31
|
+
]
|
|
32
|
+
}
|