sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
17 lines (15 loc) • 441 B
text/typescript
import {Observable} from 'rxjs'
export function readAsText(file: File, encoding?: string) {
return new Observable<string | null>((observer) => {
const reader = new FileReader()
reader.onerror = (error) => observer.error(error)
reader.onload = () => {
observer.next(reader.result as string | null)
observer.complete()
}
reader.readAsText(file, encoding)
return () => {
reader.abort()
}
})
}