@bobfrankston/iflow-direct 0.1.52 → 0.1.53
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/imap-native.js +8 -1
- package/package.json +1 -1
package/imap-native.js
CHANGED
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
* Existing callers are not affected.
|
|
8
8
|
*/
|
|
9
9
|
import * as proto from "./imap-protocol.js";
|
|
10
|
+
// Yield the event loop between buffer slices. Node has setImmediate (drains
|
|
11
|
+
// I/O + timers + IPC before resuming); browser / Android (BridgeTransport)
|
|
12
|
+
// runtimes don't, so fall back to a 0 ms timer. Reached via globalThis so this
|
|
13
|
+
// transport-agnostic package needs no node type dependency.
|
|
14
|
+
const yieldToEventLoop = typeof globalThis.setImmediate === "function"
|
|
15
|
+
? globalThis.setImmediate
|
|
16
|
+
: (cb) => { setTimeout(cb, 0); };
|
|
10
17
|
export class NativeImapClient {
|
|
11
18
|
transport;
|
|
12
19
|
transportFactory;
|
|
@@ -1208,7 +1215,7 @@ export class NativeImapClient {
|
|
|
1208
1215
|
const TIME_BUDGET_MS = 10;
|
|
1209
1216
|
while (true) {
|
|
1210
1217
|
if (performance.now() - t0 > TIME_BUDGET_MS) {
|
|
1211
|
-
|
|
1218
|
+
yieldToEventLoop(() => this.processBuffer());
|
|
1212
1219
|
return;
|
|
1213
1220
|
}
|
|
1214
1221
|
// Check for literal — `{N}` announces N octets of arbitrary data
|