Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fileasy

NAKAK101.1kISC1.1.2TypeScript support: included

media

file, download, client, typescript, javascript, check-file-type, what-MimeType, file-convert, image-compress

readme

media

fileasy

documantation

fileasy.rucuru.com

conversion

const base64ToFile: (base64: string, fileName?: string, type?: string) => File
const binaryToString: (data: ArrayBuffer | File) => Promise<string>
const fileToArrayBuffer: (file: File) => Promise<ArrayBuffer>
const fileToBase64: (file: File) => Promise<string>
// path: base64 | dataDUI | URL
const fileToHTMLImageElement: (path: string) => Promise<HTMLImageElement>
const svgToJpeg: (svgData: string | File, name?: string, fillStyle?: string) => Promise<File>
const jpegToPng: (svgData: string | File, name?: string) => Promise<File>
const pngToJpeg: (svgData: string | File, name?: string, fillStyle?: string) => Promise<File>
const svgToPng: (svgData: string | File, name?: string) => Promise<File>
const pdfToPng: (pdfFile: File, pageNum?: number) => Promise<File[]>
const pngToHex: (buffer: Buffer) => Promise<PngToHex>
const videoToPng: (videoFile: File, currentTime?: number, secLimit?: number) => Promise<string>

Warning
https://fileasy.rucuru.com/convert/pngToHex.html

get

const getInfoFromFile: (file: File) => Promise<GetInfoFromFile>
const getMimeTypeFromBuffer: (data: Buffer) => string

Warning
https://fileasy.rucuru.com/get/getMimeTypeFromBuffer.html

const getDataFromByte: (size: number) => {formatNum: number; unit: string; full: string;}
const getTypeFromDataURI: (base64: string) => string

other

const downloadToDevice: (fileData?: GetInfoFromFile | File, name?: string) => void
function downloadFromURL(url: string, type: string, name: string, fun?: ((rogress: number) => void) | undefined): Promise<File>
const selectFile: (accept?: string, maxLen?: number) => Promise<File[] | undefined>

types

type GetInfoFromFile = {
    file: File,
    path: string,
    type: string,
    name: string,
    size: number,
    stringBytes: string,
    width: number,
    height: number,
    base64: string,
    extension: string,
}

export type GetInfoFromFile = {
    file: File
    path: string
    type: string
    name: string
    size: number
    stringBytes: string
    width: number
    height: number
    base64: string
    extension: string
}

type GetMimeTypeFromBuffer =
    | 'image/png'
    | 'image/jpeg'
    | 'image/gif'
    | 'image/tiff'
    | 'image/webp'
    | 'image/svg+xml'
    | 'application/pdf'
    | 'application/msword'
    | 'video/mp4'
    | 'audio/mpeg'
    | 'application/octet-stream'

type PngToHex = {
    width: number
    height: number
    depth: number
    color: number
    compress: number
    filter: number
    interlac: number
    data: string[]
}