@papra/lecture
Version:
A simple library to extract text from files
70 lines (69 loc) • 1.91 kB
TypeScript
import { DeepPartial } from "@corentinth/chisels";
//#region src/types.d.ts
type ExtractorConfig = {
tesseract: {
languages: string[];
forceJs?: boolean;
binary?: string;
};
};
type PartialExtractorConfig = undefined | DeepPartial<ExtractorConfig>;
type Logger = {
debug: (...args: [data: Record<string, unknown>, message: string] | [message: string]) => void;
info: (...args: [data: Record<string, unknown>, message: string] | [message: string]) => void;
warn: (...args: [data: Record<string, unknown>, message: string] | [message: string]) => void;
error: (...args: [data: Record<string, unknown>, message: string] | [message: string]) => void;
};
//#endregion
//#region src/config.d.ts
declare const ocrLanguages: unknown[];
//#endregion
//#region src/extractors.usecases.d.ts
declare function extractText({
arrayBuffer,
mimeType,
config: rawConfig,
logger
}: {
arrayBuffer: ArrayBuffer;
mimeType: string;
config?: PartialExtractorConfig;
logger?: Logger;
}): Promise<{
extractorName: string | undefined;
extractorType: string | undefined;
textContent: string | undefined;
error?: Error;
subExtractorsUsed: string[];
}>;
declare function extractTextFromBlob({
blob,
...rest
}: {
blob: Blob;
config?: PartialExtractorConfig;
logger?: Logger;
}): Promise<{
extractorName: string | undefined;
extractorType: string | undefined;
textContent: string | undefined;
error?: Error;
subExtractorsUsed: string[];
}>;
declare function extractTextFromFile({
file,
...rest
}: {
file: File;
config?: PartialExtractorConfig;
logger?: Logger;
}): Promise<{
extractorName: string | undefined;
extractorType: string | undefined;
textContent: string | undefined;
error?: Error;
subExtractorsUsed: string[];
}>;
//#endregion
export { extractText, extractTextFromBlob, extractTextFromFile, ocrLanguages };
//# sourceMappingURL=index.d.ts.map