From 5d0af69a7d68b1e2f332389637a90f42890028e3 Mon Sep 17 00:00:00 2001 From: Douglas Kogut Date: Fri, 26 Apr 2024 12:46:25 -0400 Subject: [PATCH] feat: expose raw parsing function --- src/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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({