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:
10
cli.js
10
cli.js
@@ -10,6 +10,16 @@ import { promises as fs, unwatchFile } from "node:fs";
|
|||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
import path from "node:path";
|
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) {
|
function renderUsage(usage) {
|
||||||
const inputTokens = usage.input_tokens - usage.input_tokens_details.cached_tokens;
|
const inputTokens = usage.input_tokens - usage.input_tokens_details.cached_tokens;
|
||||||
const cacheTokens = usage.input_tokens_details.cached_tokens;
|
const cacheTokens = usage.input_tokens_details.cached_tokens;
|
||||||
|
|||||||
Reference in New Issue
Block a user