chompyy 0.5.0 → 0.6.0
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 +11 -0
- package/dist/agentlimits.js +77 -0
- package/dist/agentusage.js +96 -0
- package/dist/appstate.js +63 -3
- package/dist/away.js +44 -5
- package/dist/blueprint.js +3 -7
- package/dist/board.js +1 -0
- package/dist/cli.js +263 -5
- package/dist/codexquota.js +106 -0
- package/dist/codexusage.js +10 -0
- package/dist/config.js +2 -0
- package/dist/context.js +30 -0
- package/dist/costs.js +1 -0
- package/dist/demon.js +20 -0
- package/dist/label.js +33 -0
- package/dist/menu.js +17 -0
- package/dist/nightcap.js +60 -0
- package/dist/nudge.js +47 -18
- package/dist/pacing.js +16 -1
- package/dist/questions.js +71 -0
- package/dist/recap.js +74 -0
- package/dist/receipt.js +48 -0
- package/dist/recipe.js +79 -0
- package/dist/stamps.js +14 -0
- package/dist/triggers.js +5 -0
- package/dist/usage.js +21 -1
- package/dist/vendor/codeburn/antigravity.js +309 -0
- package/dist/vendor/codeburn/codex.js +429 -0
- package/dist/vendor/codeburn/copilot.js +292 -0
- package/dist/vendor/codeburn/gemini.js +195 -0
- package/dist/vendor/codeburn/grokbot.js +182 -0
- package/dist/vendor/codeburn/kimi.js +178 -0
- package/dist/vendor/codeburn/shims/chalk.js +14 -0
- package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
- package/dist/vendor/codeburn/src/act/backup.js +83 -0
- package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
- package/dist/vendor/codeburn/src/act/types.js +37 -0
- package/dist/vendor/codeburn/src/bash-utils.js +204 -0
- package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
- package/dist/vendor/codeburn/src/cache-dir.js +26 -0
- package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
- package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
- package/dist/vendor/codeburn/src/classifier.js +209 -0
- package/dist/vendor/codeburn/src/claude-identity.js +223 -0
- package/dist/vendor/codeburn/src/codex-cache.js +377 -0
- package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
- package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
- package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
- package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
- package/dist/vendor/codeburn/src/compare-stats.js +405 -0
- package/dist/vendor/codeburn/src/config.js +145 -0
- package/dist/vendor/codeburn/src/content-utils.js +56 -0
- package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
- package/dist/vendor/codeburn/src/context-tree.js +664 -0
- package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
- package/dist/vendor/codeburn/src/currency.js +189 -0
- package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
- package/dist/vendor/codeburn/src/cursor-import.js +402 -0
- package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
- package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
- package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
- package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
- package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
- package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
- package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
- package/dist/vendor/codeburn/src/format.js +118 -0
- package/dist/vendor/codeburn/src/fs-utils.js +270 -0
- package/dist/vendor/codeburn/src/git-origin.js +334 -0
- package/dist/vendor/codeburn/src/granular-history.js +328 -0
- package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
- package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
- package/dist/vendor/codeburn/src/live-sessions.js +358 -0
- package/dist/vendor/codeburn/src/math-utils.js +8 -0
- package/dist/vendor/codeburn/src/menubar-json.js +294 -0
- package/dist/vendor/codeburn/src/models.js +1879 -0
- package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
- package/dist/vendor/codeburn/src/optimize.js +4110 -0
- package/dist/vendor/codeburn/src/parse-workers.js +219 -0
- package/dist/vendor/codeburn/src/parser.js +6953 -0
- package/dist/vendor/codeburn/src/path-privacy.js +26 -0
- package/dist/vendor/codeburn/src/plans.js +135 -0
- package/dist/vendor/codeburn/src/pr-signals.js +132 -0
- package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
- package/dist/vendor/codeburn/src/provider-issues.js +30 -0
- package/dist/vendor/codeburn/src/providers/amp.js +286 -0
- package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
- package/dist/vendor/codeburn/src/providers/claude.js +551 -0
- package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
- package/dist/vendor/codeburn/src/providers/cline.js +63 -0
- package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
- package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
- package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
- package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
- package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
- package/dist/vendor/codeburn/src/providers/crush.js +226 -0
- package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
- package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
- package/dist/vendor/codeburn/src/providers/devin.js +569 -0
- package/dist/vendor/codeburn/src/providers/droid.js +324 -0
- package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
- package/dist/vendor/codeburn/src/providers/forge.js +245 -0
- package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
- package/dist/vendor/codeburn/src/providers/goose.js +252 -0
- package/dist/vendor/codeburn/src/providers/grok.js +581 -0
- package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
- package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
- package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
- package/dist/vendor/codeburn/src/providers/index.js +360 -0
- package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
- package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
- package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
- package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
- package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
- package/dist/vendor/codeburn/src/providers/mux.js +242 -0
- package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
- package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
- package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
- package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
- package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
- package/dist/vendor/codeburn/src/providers/pi.js +429 -0
- package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
- package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
- package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
- package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
- package/dist/vendor/codeburn/src/providers/types.js +5 -0
- package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
- package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
- package/dist/vendor/codeburn/src/providers/warp.js +575 -0
- package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
- package/dist/vendor/codeburn/src/providers/zed.js +187 -0
- package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
- package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
- package/dist/vendor/codeburn/src/quota/claude.js +244 -0
- package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
- package/dist/vendor/codeburn/src/quota/security.js +299 -0
- package/dist/vendor/codeburn/src/quota/types.js +1 -0
- package/dist/vendor/codeburn/src/scan-facts.js +99 -0
- package/dist/vendor/codeburn/src/session-cache.js +3040 -0
- package/dist/vendor/codeburn/src/session-count-label.js +14 -0
- package/dist/vendor/codeburn/src/session-output.js +139 -0
- package/dist/vendor/codeburn/src/session-population.js +30 -0
- package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
- package/dist/vendor/codeburn/src/sqlite.js +528 -0
- package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
- package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
- package/dist/vendor/codeburn/src/token-estimate.js +5 -0
- package/dist/vendor/codeburn/src/types.js +16 -0
- package/dist/vendor/codeburn/src/work-units.js +126 -0
- package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
- package/dist/vendor/codeburn/src/wsl.js +198 -0
- package/dist/vendor/codeburn/src/yield.js +666 -0
- package/package.json +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// @ts-nocheck: codeburn type-checks this under its own tsconfig; Chompyy adds noUncheckedIndexedAccess (see UPSTREAM.md)
|
|
2
|
+
import { availableParallelism, totalmem } from 'os';
|
|
3
|
+
import { MessageChannel, Worker } from 'worker_threads';
|
|
4
|
+
import { loadCodexParentReplayIndex } from './codex-fork-replay.js';
|
|
5
|
+
import { snapshotPricingState } from './models.js';
|
|
6
|
+
// A worker holds one file's entries plus its serialized result, and the parent
|
|
7
|
+
// buffers up to `pool.size` finished results while it installs one — both are in
|
|
8
|
+
// this budget. A flat 256 MB was measured wrong on Codex: a 260 MB rollout peaks
|
|
9
|
+
// near 430 MB per worker and scales linearly with the pool. So derive it from the
|
|
10
|
+
// average pending file instead, floored at the small-transcript figure and capped
|
|
11
|
+
// at 1 GB. Going over the budget is what turns a parallel parse into a swapping one.
|
|
12
|
+
const MIN_PER_WORKER_RSS_BYTES = 256 * 1024 * 1024;
|
|
13
|
+
const MAX_PER_WORKER_RSS_BYTES = 1024 * 1024 * 1024;
|
|
14
|
+
const PER_WORKER_RSS_OVERHEAD_BYTES = 128 * 1024 * 1024;
|
|
15
|
+
const MEMORY_BUDGET_CAP_BYTES = 2 * 1024 * 1024 * 1024;
|
|
16
|
+
const MIN_AVAILABLE_BYTES = 4 * 1024 * 1024 * 1024;
|
|
17
|
+
const MIN_FILES_PER_WORKER = 50;
|
|
18
|
+
const MIN_BYTES_PER_WORKER = 200 * 1024 * 1024;
|
|
19
|
+
// Below this a parse is warm/incremental and the thread startup + result transfer
|
|
20
|
+
// costs more than the parallelism buys. Bytes, not file count: 250 pending files
|
|
21
|
+
// holding under a megabyte between them spawn threads that make the run ~5%
|
|
22
|
+
// SLOWER, and the file count only starts paying for itself around 400.
|
|
23
|
+
const MIN_PENDING_BYTES = 200 * 1024 * 1024;
|
|
24
|
+
// `process.availableMemory()` respects a container's cgroup / rlimit, which is the
|
|
25
|
+
// case this gate exists for; where it is absent it falls back to total RAM. Free
|
|
26
|
+
// memory is deliberately NOT used: on macOS `os.freemem()` counts free pages, not
|
|
27
|
+
// available memory, and reads as a few hundred MB on an idle 128 GB machine — a
|
|
28
|
+
// gate built on it turns the feature on and off at random.
|
|
29
|
+
function currentSystemCapacity() {
|
|
30
|
+
return {
|
|
31
|
+
cores: availableParallelism(),
|
|
32
|
+
availableBytes: typeof process.availableMemory === 'function' ? process.availableMemory() : totalmem(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/// Decide how many parse worker threads a pending workload earns. Returning 0
|
|
36
|
+
/// means "parse serially" — the only behaviour before this existed, and still
|
|
37
|
+
/// the behaviour for every warm run, every small corpus, and every low-spec box.
|
|
38
|
+
export function decideParseWorkers(pending, sys = currentSystemCapacity(), env = process.env) {
|
|
39
|
+
// Every reason carries the full decision input, so a support log line explains
|
|
40
|
+
// itself without a second run.
|
|
41
|
+
const inputs = `${sys.cores} cores, ${Math.round(sys.availableBytes / 1e9 * 10) / 10} GB available, ${pending.files} pending files / ${Math.round(pending.bytes / 1e6)} MB`;
|
|
42
|
+
const override = env['CODEBURN_PARSE_WORKERS'];
|
|
43
|
+
if (override !== undefined && override !== '') {
|
|
44
|
+
const n = Number(override);
|
|
45
|
+
if (!Number.isFinite(n) || n < 0)
|
|
46
|
+
return { workers: 0, reason: `invalid CODEBURN_PARSE_WORKERS=${override}` };
|
|
47
|
+
const capped = Math.min(Math.floor(n), sys.cores);
|
|
48
|
+
return { workers: capped, reason: `${capped === 0 ? 'forced serial' : 'forced'} by CODEBURN_PARSE_WORKERS=${override}; ${inputs}` };
|
|
49
|
+
}
|
|
50
|
+
// Workload gates first, so a warm run's log line says "warm", not whatever the
|
|
51
|
+
// machine happened to look like at that moment.
|
|
52
|
+
if (pending.bytes < MIN_PENDING_BYTES)
|
|
53
|
+
return { workers: 0, reason: `below ${Math.round(MIN_PENDING_BYTES / 1e6)} MB pending; ${inputs}` };
|
|
54
|
+
if (sys.cores <= 2)
|
|
55
|
+
return { workers: 0, reason: `too few cores; ${inputs}` };
|
|
56
|
+
if (sys.availableBytes < MIN_AVAILABLE_BYTES)
|
|
57
|
+
return { workers: 0, reason: `below ${Math.round(MIN_AVAILABLE_BYTES / 1e9)} GB available memory; ${inputs}` };
|
|
58
|
+
const memoryBudget = Math.min(0.25 * sys.availableBytes, MEMORY_BUDGET_CAP_BYTES);
|
|
59
|
+
const perWorker = Math.min(MAX_PER_WORKER_RSS_BYTES, Math.max(MIN_PER_WORKER_RSS_BYTES, 2 * (pending.bytes / Math.max(1, pending.files)) + PER_WORKER_RSS_OVERHEAD_BYTES));
|
|
60
|
+
// Files and bytes each earn threads on their own: a few hundred huge rollouts
|
|
61
|
+
// are as parallelisable as a few thousand small transcripts, and gating the
|
|
62
|
+
// count on files alone would hand a 6 GB / 60-file workload a single thread.
|
|
63
|
+
const workers = Math.min(sys.cores - 1, Math.floor(memoryBudget / perWorker), Math.max(Math.floor(pending.files / MIN_FILES_PER_WORKER), Math.floor(pending.bytes / MIN_BYTES_PER_WORKER)));
|
|
64
|
+
return { workers, reason: inputs };
|
|
65
|
+
}
|
|
66
|
+
// In dist the entry is the bundled sibling of this module and a worker can load
|
|
67
|
+
// it directly. Running from source (tsx, vitest) the entry is TypeScript, and a
|
|
68
|
+
// worker thread inherits none of the parent's loader hooks — so register tsx's
|
|
69
|
+
// inside the thread before importing. tsx is a devDependency, which is exactly
|
|
70
|
+
// the only situation where the entry can be a .ts file at all.
|
|
71
|
+
function workerBootstrap(entryUrl) {
|
|
72
|
+
if (!entryUrl.endsWith('.ts'))
|
|
73
|
+
return { source: new URL(entryUrl), eval: false };
|
|
74
|
+
return {
|
|
75
|
+
eval: true,
|
|
76
|
+
// Chained, not awaited: the eval scope is CommonJS, and a top-level await of
|
|
77
|
+
// the entry re-enters it as a require(esm) cycle.
|
|
78
|
+
source: `
|
|
79
|
+
process.noDeprecation = true
|
|
80
|
+
import('tsx/esm/api').then(tsx => { tsx.register(); return import(${JSON.stringify(entryUrl)}) })
|
|
81
|
+
`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function workerEntryUrl() {
|
|
85
|
+
const ext = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
|
|
86
|
+
return new URL(`./parse-worker${ext}`, import.meta.url).href;
|
|
87
|
+
}
|
|
88
|
+
function serveParentReplay(port) {
|
|
89
|
+
port.on('message', ({ id, args }) => {
|
|
90
|
+
loadCodexParentReplayIndex(...args).then(index => port.postMessage({ id, index }), (err) => port.postMessage({ id, error: err instanceof Error ? err.message : String(err) }));
|
|
91
|
+
});
|
|
92
|
+
port.unref();
|
|
93
|
+
}
|
|
94
|
+
export class ParseWorkerPool {
|
|
95
|
+
workers = [];
|
|
96
|
+
idle = [];
|
|
97
|
+
inflight = new Map();
|
|
98
|
+
queue = [];
|
|
99
|
+
replayPorts = [];
|
|
100
|
+
closed = false;
|
|
101
|
+
constructor(size) {
|
|
102
|
+
const boot = workerBootstrap(workerEntryUrl());
|
|
103
|
+
const workerData = { pricing: snapshotPricingState() };
|
|
104
|
+
try {
|
|
105
|
+
for (let i = 0; i < size; i++) {
|
|
106
|
+
const { port1, port2 } = new MessageChannel();
|
|
107
|
+
serveParentReplay(port1);
|
|
108
|
+
this.replayPorts.push(port1);
|
|
109
|
+
const worker = new Worker(boot.source, { eval: boot.eval, workerData: { ...workerData, replayPort: port2 }, transferList: [port2] });
|
|
110
|
+
worker.on('message', (msg) => this.settle(worker, msg));
|
|
111
|
+
worker.on('error', (err) => this.settle(worker, { error: err.message }, true));
|
|
112
|
+
worker.on('exit', () => this.drop(worker));
|
|
113
|
+
this.workers.push(worker);
|
|
114
|
+
this.idle.push(worker);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
for (const w of this.workers)
|
|
119
|
+
void w.terminate();
|
|
120
|
+
for (const p of this.replayPorts)
|
|
121
|
+
p.close();
|
|
122
|
+
this.workers.length = 0;
|
|
123
|
+
this.idle.length = 0;
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get size() {
|
|
128
|
+
return this.workers.length;
|
|
129
|
+
}
|
|
130
|
+
/// Parse one file off-thread. Never rejects: a worker-side failure (or a dead
|
|
131
|
+
/// pool) comes back as `ok: false` so the caller can fall back to an in-process
|
|
132
|
+
/// parse and never lose a file to a crashed thread.
|
|
133
|
+
submit(job) {
|
|
134
|
+
return new Promise((resolve) => {
|
|
135
|
+
if (this.closed || this.workers.length === 0) {
|
|
136
|
+
resolve({ ok: false, error: 'parse worker pool unavailable' });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.queue.push({ job, resolve: resolve });
|
|
140
|
+
this.pump();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async close() {
|
|
144
|
+
this.closed = true;
|
|
145
|
+
const pending = [...this.queue];
|
|
146
|
+
this.queue.length = 0;
|
|
147
|
+
for (const task of pending)
|
|
148
|
+
task.resolve({ ok: false, error: 'parse worker pool closed' });
|
|
149
|
+
await Promise.all(this.workers.map(w => w.terminate()));
|
|
150
|
+
for (const p of this.replayPorts)
|
|
151
|
+
p.close();
|
|
152
|
+
this.workers.length = 0;
|
|
153
|
+
this.idle.length = 0;
|
|
154
|
+
this.inflight.clear();
|
|
155
|
+
}
|
|
156
|
+
pump() {
|
|
157
|
+
while (this.queue.length > 0 && this.idle.length > 0) {
|
|
158
|
+
const worker = this.idle.pop();
|
|
159
|
+
const task = this.queue.shift();
|
|
160
|
+
this.inflight.set(worker, task);
|
|
161
|
+
worker.postMessage(task.job);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
settle(worker, msg, fatal = false) {
|
|
165
|
+
const task = this.inflight.get(worker);
|
|
166
|
+
this.inflight.delete(worker);
|
|
167
|
+
if (task) {
|
|
168
|
+
if (msg.error !== undefined)
|
|
169
|
+
task.resolve({ ok: false, error: msg.error });
|
|
170
|
+
else
|
|
171
|
+
task.resolve({ ok: true, parsed: msg.json == null ? null : JSON.parse(msg.json) });
|
|
172
|
+
}
|
|
173
|
+
if (fatal)
|
|
174
|
+
return;
|
|
175
|
+
if (!this.closed) {
|
|
176
|
+
this.idle.push(worker);
|
|
177
|
+
this.pump();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// A thread that died takes its queue slot with it; the remaining files are
|
|
181
|
+
// handed back for a serial parse rather than being lost.
|
|
182
|
+
drop(worker) {
|
|
183
|
+
const i = this.workers.indexOf(worker);
|
|
184
|
+
if (i >= 0)
|
|
185
|
+
this.workers.splice(i, 1);
|
|
186
|
+
const j = this.idle.indexOf(worker);
|
|
187
|
+
if (j >= 0)
|
|
188
|
+
this.idle.splice(j, 1);
|
|
189
|
+
const task = this.inflight.get(worker);
|
|
190
|
+
if (task) {
|
|
191
|
+
this.inflight.delete(worker);
|
|
192
|
+
task.resolve({ ok: false, error: 'parse worker exited' });
|
|
193
|
+
}
|
|
194
|
+
if (this.workers.length === 0) {
|
|
195
|
+
const pending = [...this.queue];
|
|
196
|
+
this.queue.length = 0;
|
|
197
|
+
for (const t of pending)
|
|
198
|
+
t.resolve({ ok: false, error: 'all parse workers exited' });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/// Yield results for `jobs` in the SAME order they were given, no matter which
|
|
203
|
+
/// worker finishes first. Keeps exactly `pool.size` files in flight, so at most
|
|
204
|
+
/// that many parsed results are buffered while the caller installs one.
|
|
205
|
+
export async function* parseFilesInOrder(pool, jobs) {
|
|
206
|
+
const inflight = [];
|
|
207
|
+
let next = 0;
|
|
208
|
+
const fill = () => {
|
|
209
|
+
while (inflight.length < Math.max(1, pool.size) && next < jobs.length) {
|
|
210
|
+
inflight.push(pool.submit(jobs[next++]));
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
fill();
|
|
214
|
+
for (let i = 0; i < jobs.length; i++) {
|
|
215
|
+
const result = await inflight.shift();
|
|
216
|
+
fill();
|
|
217
|
+
yield result;
|
|
218
|
+
}
|
|
219
|
+
}
|