Add util function docstring

This commit is contained in:
Krzysztof Wolski 2022-09-01 17:18:32 +02:00
parent b2f84b51c8
commit 5b7bb5d878

View file

@ -5,6 +5,12 @@ import { APL, AuthData } from "./apl";
const debug = debugPkg.debug("FileAPL");
/**
* Load auth data from a file and return it as AuthData format.
* In case of incomplete or invalid data, return `undefined`.
*
* @param {string} fileName
*/
export const loadDataFromFile = async (fileName: string): Promise<AuthData | undefined> => {
debug(`Load auth data from the ${fileName} file`);
let parsedData: Record<string, string> = {};
@ -22,6 +28,13 @@ export const loadDataFromFile = async (fileName: string): Promise<AuthData | und
return undefined;
};
/**
* Save auth data to file.
* When `authData` argument is empty, will overwrite file with empty values.
*
* @param {string} fileName
* @param {AuthData} [authData]
*/
export const saveDataToFile = async (fileName: string, authData?: AuthData) => {
debug(`Save auth data to the ${fileName} file`);
const newData = authData ? JSON.stringify(authData) : "{}";