diff --git a/src/index.ts b/src/index.ts index d3fc2c8..9ee5378 100644 --- a/src/index.ts +++ b/src/index.ts @@ -395,7 +395,12 @@ type ParsedMetadata = | { error: Error; metadata?: undefined } | { error?: undefined; metadata: GGUFMetadata } -const parseMetadata = async (filePath: string): Promise => { +type RawMetadata = + | { error: Error } + | { error?: null; metadata: Record } +export const parseRawMetadata = async ( + filePath: string, +): Promise => { const metadata = await new Promise< { error: Error } | { error?: null; metadata: Record } >((resolve) => { @@ -554,6 +559,12 @@ const parseMetadata = async (filePath: string): Promise => { }) }) + return metadata +} + +const parseMetadata = async (filePath: string): Promise => { + const metadata = await parseRawMetadata(filePath) + if (metadata.error) return { error: metadata.error } const validationError = validateMetadata({