feat: import environments from insomnia (#3625)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
16
packages/hoppscotch-common/src/helpers/functional/yaml.ts
Normal file
16
packages/hoppscotch-common/src/helpers/functional/yaml.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import yaml from "js-yaml"
|
||||
import * as O from "fp-ts/Option"
|
||||
import { safeParseJSON } from "./json"
|
||||
import { pipe } from "fp-ts/function"
|
||||
|
||||
export const safeParseYAML = (str: string) => O.tryCatch(() => yaml.load(str))
|
||||
|
||||
export const safeParseJSONOrYAML = (str: string) =>
|
||||
pipe(
|
||||
str,
|
||||
safeParseJSON,
|
||||
O.match(
|
||||
() => safeParseYAML(str),
|
||||
(data) => O.of(data)
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user