mail-parser-wasm 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -0
- package/mail_parser_wasm.d.ts +21 -0
- package/mail_parser_wasm.js +4 -0
- package/mail_parser_wasm_bg.js +192 -0
- package/mail_parser_wasm_bg.wasm +0 -0
- package/package.json +18 -0
package/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
/* tslint:disable */
|
2
|
+
/* eslint-disable */
|
3
|
+
/**
|
4
|
+
* @param {string} raw_message
|
5
|
+
* @returns {MessageResult}
|
6
|
+
*/
|
7
|
+
export function parse_message(raw_message: string): MessageResult;
|
8
|
+
/**
|
9
|
+
*/
|
10
|
+
export class MessageResult {
|
11
|
+
free(): void;
|
12
|
+
/**
|
13
|
+
*/
|
14
|
+
readonly content: string | undefined;
|
15
|
+
/**
|
16
|
+
*/
|
17
|
+
readonly sender: string | undefined;
|
18
|
+
/**
|
19
|
+
*/
|
20
|
+
readonly subject: string | undefined;
|
21
|
+
}
|
@@ -0,0 +1,192 @@
|
|
1
|
+
let wasm;
|
2
|
+
export function __wbg_set_wasm(val) {
|
3
|
+
wasm = val;
|
4
|
+
}
|
5
|
+
|
6
|
+
|
7
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
8
|
+
|
9
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
10
|
+
|
11
|
+
cachedTextDecoder.decode();
|
12
|
+
|
13
|
+
let cachedUint8Memory0 = null;
|
14
|
+
|
15
|
+
function getUint8Memory0() {
|
16
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
17
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
18
|
+
}
|
19
|
+
return cachedUint8Memory0;
|
20
|
+
}
|
21
|
+
|
22
|
+
function getStringFromWasm0(ptr, len) {
|
23
|
+
ptr = ptr >>> 0;
|
24
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
25
|
+
}
|
26
|
+
|
27
|
+
let cachedInt32Memory0 = null;
|
28
|
+
|
29
|
+
function getInt32Memory0() {
|
30
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
31
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
32
|
+
}
|
33
|
+
return cachedInt32Memory0;
|
34
|
+
}
|
35
|
+
|
36
|
+
let WASM_VECTOR_LEN = 0;
|
37
|
+
|
38
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
39
|
+
|
40
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
41
|
+
|
42
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
43
|
+
? function (arg, view) {
|
44
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
45
|
+
}
|
46
|
+
: function (arg, view) {
|
47
|
+
const buf = cachedTextEncoder.encode(arg);
|
48
|
+
view.set(buf);
|
49
|
+
return {
|
50
|
+
read: arg.length,
|
51
|
+
written: buf.length
|
52
|
+
};
|
53
|
+
});
|
54
|
+
|
55
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
56
|
+
|
57
|
+
if (realloc === undefined) {
|
58
|
+
const buf = cachedTextEncoder.encode(arg);
|
59
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
60
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
61
|
+
WASM_VECTOR_LEN = buf.length;
|
62
|
+
return ptr;
|
63
|
+
}
|
64
|
+
|
65
|
+
let len = arg.length;
|
66
|
+
let ptr = malloc(len, 1) >>> 0;
|
67
|
+
|
68
|
+
const mem = getUint8Memory0();
|
69
|
+
|
70
|
+
let offset = 0;
|
71
|
+
|
72
|
+
for (; offset < len; offset++) {
|
73
|
+
const code = arg.charCodeAt(offset);
|
74
|
+
if (code > 0x7F) break;
|
75
|
+
mem[ptr + offset] = code;
|
76
|
+
}
|
77
|
+
|
78
|
+
if (offset !== len) {
|
79
|
+
if (offset !== 0) {
|
80
|
+
arg = arg.slice(offset);
|
81
|
+
}
|
82
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
83
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
84
|
+
const ret = encodeString(arg, view);
|
85
|
+
|
86
|
+
offset += ret.written;
|
87
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
88
|
+
}
|
89
|
+
|
90
|
+
WASM_VECTOR_LEN = offset;
|
91
|
+
return ptr;
|
92
|
+
}
|
93
|
+
/**
|
94
|
+
* @param {string} raw_message
|
95
|
+
* @returns {MessageResult}
|
96
|
+
*/
|
97
|
+
export function parse_message(raw_message) {
|
98
|
+
const ptr0 = passStringToWasm0(raw_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
99
|
+
const len0 = WASM_VECTOR_LEN;
|
100
|
+
const ret = wasm.parse_message(ptr0, len0);
|
101
|
+
return MessageResult.__wrap(ret);
|
102
|
+
}
|
103
|
+
|
104
|
+
const MessageResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
105
|
+
? { register: () => {}, unregister: () => {} }
|
106
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_messageresult_free(ptr >>> 0));
|
107
|
+
/**
|
108
|
+
*/
|
109
|
+
export class MessageResult {
|
110
|
+
|
111
|
+
static __wrap(ptr) {
|
112
|
+
ptr = ptr >>> 0;
|
113
|
+
const obj = Object.create(MessageResult.prototype);
|
114
|
+
obj.__wbg_ptr = ptr;
|
115
|
+
MessageResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
116
|
+
return obj;
|
117
|
+
}
|
118
|
+
|
119
|
+
__destroy_into_raw() {
|
120
|
+
const ptr = this.__wbg_ptr;
|
121
|
+
this.__wbg_ptr = 0;
|
122
|
+
MessageResultFinalization.unregister(this);
|
123
|
+
return ptr;
|
124
|
+
}
|
125
|
+
|
126
|
+
free() {
|
127
|
+
const ptr = this.__destroy_into_raw();
|
128
|
+
wasm.__wbg_messageresult_free(ptr);
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* @returns {string | undefined}
|
132
|
+
*/
|
133
|
+
get sender() {
|
134
|
+
try {
|
135
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
136
|
+
wasm.messageresult_sender(retptr, this.__wbg_ptr);
|
137
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
138
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
139
|
+
let v1;
|
140
|
+
if (r0 !== 0) {
|
141
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
142
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
143
|
+
}
|
144
|
+
return v1;
|
145
|
+
} finally {
|
146
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
/**
|
150
|
+
* @returns {string | undefined}
|
151
|
+
*/
|
152
|
+
get subject() {
|
153
|
+
try {
|
154
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
155
|
+
wasm.messageresult_subject(retptr, this.__wbg_ptr);
|
156
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
157
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
158
|
+
let v1;
|
159
|
+
if (r0 !== 0) {
|
160
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
161
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
162
|
+
}
|
163
|
+
return v1;
|
164
|
+
} finally {
|
165
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* @returns {string | undefined}
|
170
|
+
*/
|
171
|
+
get content() {
|
172
|
+
try {
|
173
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
174
|
+
wasm.messageresult_content(retptr, this.__wbg_ptr);
|
175
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
176
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
177
|
+
let v1;
|
178
|
+
if (r0 !== 0) {
|
179
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
180
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
181
|
+
}
|
182
|
+
return v1;
|
183
|
+
} finally {
|
184
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
export function __wbindgen_throw(arg0, arg1) {
|
190
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
191
|
+
};
|
192
|
+
|
Binary file
|
package/package.json
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"name": "mail-parser-wasm",
|
3
|
+
"description": "A simple mail parser for wasm",
|
4
|
+
"version": "0.1.2",
|
5
|
+
"license": "MIT",
|
6
|
+
"files": [
|
7
|
+
"mail_parser_wasm_bg.wasm",
|
8
|
+
"mail_parser_wasm.js",
|
9
|
+
"mail_parser_wasm_bg.js",
|
10
|
+
"mail_parser_wasm.d.ts"
|
11
|
+
],
|
12
|
+
"module": "mail_parser_wasm.js",
|
13
|
+
"types": "mail_parser_wasm.d.ts",
|
14
|
+
"sideEffects": [
|
15
|
+
"./mail_parser_wasm.js",
|
16
|
+
"./snippets/*"
|
17
|
+
]
|
18
|
+
}
|