refactor: rename to prettyPrintJSON and add jsdoc

This commit is contained in:
Andrew Bastin
2022-05-03 18:05:39 +05:30
parent f84b67ec39
commit a3d92c862c
3 changed files with 11 additions and 6 deletions

View File

@@ -8,5 +8,10 @@ import * as O from "fp-ts/Option"
export const safeParseJSON = (str: string): O.Option<object> =>
O.tryCatch(() => JSON.parse(str))
export const prettyPrintStringifyJSON = (jsonObject: any): O.Option<string> =>
O.tryCatch(() => JSON.stringify(jsonObject, null, "\t"))
/**
* Generates a prettified JSON representation of an object
* @param obj The object to get the representation of
* @returns The prettified JSON string of the object
*/
export const prettyPrintJSON = (obj: unknown): O.Option<string> =>
O.tryCatch(() => JSON.stringify(obj, null, "\t"))