@bobfrankston/mailx-store 0.1.22 → 0.1.23
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/package.json +1 -1
- package/parse-serial.d.ts +4 -3
- package/parse-serial.js +37 -7
package/package.json
CHANGED
package/parse-serial.d.ts
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* pool is built.
|
|
28
28
|
*/
|
|
29
29
|
import { type ParsedMail, type Source } from "mailparser";
|
|
30
|
-
/** Serialized wrapper around `mailparser.simpleParser`.
|
|
31
|
-
*
|
|
32
|
-
|
|
30
|
+
/** Serialized wrapper around `mailparser.simpleParser`. `priority` defaults
|
|
31
|
+
* to "foreground" — only sync/background callers should pass "background"
|
|
32
|
+
* so user clicks aren't stuck behind a back-fill. */
|
|
33
|
+
export declare function parseSerial(source: Source, priority?: "foreground" | "background"): Promise<ParsedMail>;
|
|
33
34
|
//# sourceMappingURL=parse-serial.d.ts.map
|
package/parse-serial.js
CHANGED
|
@@ -27,12 +27,42 @@
|
|
|
27
27
|
* pool is built.
|
|
28
28
|
*/
|
|
29
29
|
import { simpleParser } from "mailparser";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const _head = []; // UI / foreground — drained first
|
|
31
|
+
const _tail = []; // sync / background
|
|
32
|
+
let _pumping = false;
|
|
33
|
+
async function pump() {
|
|
34
|
+
if (_pumping)
|
|
35
|
+
return;
|
|
36
|
+
_pumping = true;
|
|
37
|
+
try {
|
|
38
|
+
for (;;) {
|
|
39
|
+
const next = _head.shift() ?? _tail.shift();
|
|
40
|
+
if (!next)
|
|
41
|
+
break;
|
|
42
|
+
try {
|
|
43
|
+
const parsed = await simpleParser(next.source);
|
|
44
|
+
next.resolve(parsed);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
next.reject(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
_pumping = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Serialized wrapper around `mailparser.simpleParser`. `priority` defaults
|
|
56
|
+
* to "foreground" — only sync/background callers should pass "background"
|
|
57
|
+
* so user clicks aren't stuck behind a back-fill. */
|
|
58
|
+
export async function parseSerial(source, priority = "foreground") {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const entry = { source, resolve, reject };
|
|
61
|
+
if (priority === "foreground")
|
|
62
|
+
_head.push(entry);
|
|
63
|
+
else
|
|
64
|
+
_tail.push(entry);
|
|
65
|
+
pump();
|
|
66
|
+
});
|
|
37
67
|
}
|
|
38
68
|
//# sourceMappingURL=parse-serial.js.map
|