Promise-based FileReader
implementation.
node
npm install @myrear/file_reader_promise
deno
import {
FileReader,
readAs,
} from 'https://deno.land/x/file_reader_promise/mod.ts'
This library provides 2 modules:
readAs
FileReader
: Thin wrapper class for the web standardFileReader
class
const dataUrl: string = await readAs(reader, file, 'DataURL')
const arrayBuffer: ArrayBuffer = await readAs(reader, file, 'ArrayBuffer')
const dataUrl: string = await new FileReader().readAsDataURL(file)
const arrayBuffer: ArrayBuffer = await new FileReader().readAsArrayBuffer(file)