fix: json linting not working on raw body + small ts corrections

This commit is contained in:
Andrew Bastin
2022-01-22 22:16:27 +05:30
parent 238e41ccda
commit 3bb65f2115
2 changed files with 70 additions and 17 deletions

View File

@@ -0,0 +1,19 @@
import * as TO from "fp-ts/TaskOption"
export const readFileAsText = (file: File) =>
TO.tryCatch(
() =>
new Promise<string>((resolve, reject) => {
const reader = new FileReader()
reader.onload = () => {
resolve(reader.result as string)
}
reader.onerror = () => {
reject(new Error("File err"))
}
reader.readAsText(file)
})
)