-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.ts
56 lines (49 loc) · 1.42 KB
/
example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { DecomposedRegex, DecomposedRegexJson, testDecomposedRegex } from "./src";
import helloTestEmail from "./unit_tests/hello_eml";
async function testEmailBody() {
// Wait for wasm to initialize
await new Promise((r) => setTimeout(r, 300));
const decomposedRegex: DecomposedRegex = {
name: "Hello Pattern",
maxLength: 4000,
location: "body",
parts: [
{
isPublic: false,
regexDef: "Hello ",
},
{
isPublic: true,
regexDef: "[^,]+",
},
{
isPublic: false,
regexDef: "!",
},
],
};
const result = await testDecomposedRegex(helloTestEmail, decomposedRegex, false);
console.log("result private field not revealed: ", result);
const result2 = await testDecomposedRegex(helloTestEmail, decomposedRegex, true);
console.log("result private fields revealed: ", result2);
}
testEmailBody();
async function testEmailHeader() {
// Wait for wasm to initialize
await new Promise((r) => setTimeout(r, 300));
// You can also use the snake case version
const decomposedRegex: DecomposedRegexJson = {
name: "Find sender Pattern",
max_length: 3000,
location: "header",
parts: [
{
is_public: true,
regex_def: "[email protected]",
},
],
};
const result = await testDecomposedRegex(helloTestEmail, decomposedRegex, false);
console.log("header result", result);
}
testEmailHeader();