Merge branch 'orphan-pr/2243' into 2087-openapi

This commit is contained in:
Andrew Bastin
2022-06-29 22:14:14 +05:30
committed by GitHub
165 changed files with 8076 additions and 3222 deletions

View File

@@ -1,4 +1,5 @@
import * as O from "fp-ts/Option"
import { flow } from "fp-ts/function"
/**
* Checks and Parses JSON string
@@ -15,3 +16,10 @@ export const safeParseJSON = (str: string): O.Option<object> =>
*/
export const prettyPrintJSON = (obj: unknown): O.Option<string> =>
O.tryCatch(() => JSON.stringify(obj, null, "\t"))
/**
* Checks if given string is a JSON string
* @param str Raw string to be checked
* @returns If string is a JSON string
*/
export const isJSON = flow(safeParseJSON, O.isSome)