A continuation of Janady13/llms-txt-hub / scripts/pr-backfill-dry-run.ts. The complete source identity, every recorded occurrence, and linked equations are on its first page.
Source transcript · continued
Download complete source text ↓1,538 lines · 39.7 KB
* Truncate long output fields for the streaming table.
*/
function truncate(value: string, maxLength: number): string {
if (value.length <= maxLength) {
return value
}
return `${value.slice(0, maxLength - 3)}...`
}
/**
* Sleep for the given number of milliseconds.
*/
function sleep(milliseconds: number): Promise<void> {
return new Promise(resolve => {
setTimeout(resolve, milliseconds)
})
}
/**
* Ensure an unknown value is an object record.
*/
function ensureRecord(value: unknown): Record<string, unknown> {
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
return value
}
throw new Error('Frontmatter payload is not an object.')
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main().catch(error => {
const message = error instanceof Error ? error.message : String(error)
process.stderr.write(`${message}\n`)
process.exitCode = 1
})
}