From 404cdd1d41a2c77f06e9ea35e8db30b3c7199dae Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Mon, 14 Feb 2022 14:54:21 -0500 Subject: [PATCH] chore: document older methods --- src/index.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 3f07bf2..6f61664 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,10 @@ -export * from './release' +export * from 'release' +/** + * Parse raw file contents that conform to the APT key-value format + * @param data Raw data + * @returns A key-value map of raw-value strings + */ export function parseKV(data: string) { const cleanedData = data.replaceAll(/\r\n|\r|\n/g, '\n').replaceAll(/\0/g, '').normalize().trim() const lineChunks = cleanedData.split('\n') // We know it will always be \n because of our cleanup @@ -59,12 +64,24 @@ export function parseKV(data: string) { return fields } +/** + * Parse raw file contents of a packages file and retrieve a map of keys and values + * + * @param data Raw string contents from a Packages file + * @returns Map of string keys and values + */ export function parsePackages(data: string) { const cleanedData = data.replaceAll(/\r\n|\r|\n/g, '\n').replaceAll(/\0/g, '').normalize().trim() const packageChunks = cleanedData.split('\n\n') // We know it will always be \n\n because of our cleanup return packageChunks.map(chunk => parseKV(chunk)) } +/** + * Parse raw file contents of a control file and retrieve a map of keys and values + * + * @param data Raw string contents from a control file + * @returns Map of string keys and values + */ export function parseControl(data: string) { return parsePackages(data) }