feat: import environments from insomnia (#3625)

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
Akash K
2023-12-13 19:15:39 +05:30
committed by GitHub
parent 3ae49ca483
commit a8cc569786
5 changed files with 172 additions and 10 deletions

View 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)
)
)