Add Array.fromAsync polyfill in cli.js for better async iterable support. This enhancement improves compatibility with async data processing in the CLI environment.

This commit is contained in:
sebseb7
2025-08-12 22:07:48 +00:00
parent 14305859de
commit 58d8c352f3

10
cli.js
View File

@@ -10,6 +10,16 @@ import { promises as fs, unwatchFile } from "node:fs";
import { fileURLToPath } from "node:url";
import path from "node:path";
if (!Array.fromAsync) {
Array.fromAsync = async function fromAsync(asyncIterable) {
const array = [];
for await (const item of asyncIterable) {
array.push(item);
}
return array;
};
}
function renderUsage(usage) {
const inputTokens = usage.input_tokens - usage.input_tokens_details.cached_tokens;
const cacheTokens = usage.input_tokens_details.cached_tokens;