Skip to content

Commit

Permalink
Added Bindings for File Reader API
Browse files Browse the repository at this point in the history
  • Loading branch information
Redfire75369 committed Nov 8, 2023
1 parent 370f27d commit b56ca16
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 0 deletions.
69 changes: 69 additions & 0 deletions bindings/globals/flow/file.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
declare type BlobPart = BufferSource | Blob | String;

declare type EndingType = "transparent" | "native";

declare interface BlobOptions {
type?: string,
endings?: EndingType,
}

declare class Blob {
constructor(blobParts?: BlobPart[], options?: BlobOptions): Blob;

get size(): number;

get type(): string;

slice(start?: number, end?: number, type?: string): Blob;

text(): Promise<string>;

arrayBuffer(): Promise<ArrayBuffer>;
}

declare interface FileOptions extends BlobOptions {
lastModified?: number,
}

declare class File extends Blob {
constructor(blobParts?: BlobPart[], options?: FileOptions): File;

get name(): string;

get lastModified(): number;
}

declare class FileReader {
constructor(): FileReader;

static EMPTY: number;
static LOADING: number;
static DONE: number;

get readyState(): number;

get result(): string | ArrayBuffer | null;

get error(): Error | null;

readAsArrayBuffer(blob: Blob): void;

readAsBinaryString(blob: Blob): void;

readAsText(blob: Blob, encoding?: string): void;

readAsDataURL(blob: Blob): void;
}


declare class FileReaderSync {
constructor(): FileReaderSync;

readAsArrayBuffer(blob: Blob): ArrayBuffer;

readAsBinaryString(blob: Blob): string;

readAsText(blob: Blob, encoding?: string): string;

readAsDataURL(blob: Blob): string;
}
69 changes: 69 additions & 0 deletions bindings/globals/typescript/file.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
declare type BlobPart = BufferSource | Blob | String;

declare type EndingType = "transparent" | "native";

declare interface BlobOptions {
type?: string,
endings?: EndingType,
}

declare class Blob {
constructor(blobParts?: BlobPart[], options?: BlobOptions);

get size(): number;

get type(): string;

slice(start?: number, end?: number, type?: string): Blob;

text(): Promise<string>;

arrayBuffer(): Promise<ArrayBuffer>;
}

declare interface FileOptions extends BlobOptions {
lastModified?: number,
}

declare class File extends Blob {
constructor(blobParts?: BlobPart[], options?: FileOptions);

get name(): string;

get lastModified(): number;
}

declare class FileReader {
static EMPTY: number;
static LOADING: number;
static DONE: number;

constructor();

get readyState(): number;

get result(): string | ArrayBuffer | null;

get error(): Error | null;

readAsArrayBuffer(blob: Blob): void;

readAsBinaryString(blob: Blob): void;

readAsText(blob: Blob, encoding?: string): void;

readAsDataURL(blob: Blob): void;
}


declare class FileReaderSync {
constructor();

readAsArrayBuffer(blob: Blob): ArrayBuffer;

readAsBinaryString(blob: Blob): string;

readAsText(blob: Blob, encoding?: string): string;

readAsDataURL(blob: Blob): string;
}

0 comments on commit b56ca16

Please sign in to comment.