refactor: realtime log entry revamp (#2240)
Co-authored-by: liyasthomas <liyascthomas@gmail.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
committed by
GitHub
parent
127bd7318f
commit
fb1da491d8
@@ -1,4 +1,5 @@
|
||||
import * as O from "fp-ts/Option"
|
||||
import { flow } from "fp-ts/function"
|
||||
|
||||
/**
|
||||
* Checks and Parses JSON string
|
||||
@@ -7,3 +8,10 @@ import * as O from "fp-ts/Option"
|
||||
*/
|
||||
export const safeParseJSON = (str: string): O.Option<object> =>
|
||||
O.tryCatch(() => JSON.parse(str))
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
||||
Reference in New Issue
Block a user