refactor: return type
This commit is contained in:
parent
6858cf4103
commit
b717c7689c
1 changed files with 8 additions and 4 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { createWorker, ImageLike, RecognizeResult } from 'tesseract.js';
|
||||
import { createWorker, ImageLike, RecognizeResult, Worker } from 'tesseract.js';
|
||||
|
||||
import { parseMRZ } from './mrz';
|
||||
|
||||
let worker: Tesseract.Worker;
|
||||
let worker: Worker;
|
||||
|
||||
export function runOcr(image: ImageLike): Promise<void>;
|
||||
export function runOcr(image: ImageLike): Promise<RecognizeResult>;
|
||||
export function runOcr<
|
||||
CallbackFunction extends (result: RecognizeResult) => void,
|
||||
>(
|
||||
|
|
@ -20,7 +20,11 @@ export async function runOcr<T extends (result: RecognizeResult) => void>(
|
|||
langPath: '/ocr-data',
|
||||
});
|
||||
}
|
||||
if (callback) return callback(await worker.recognize(image));
|
||||
|
||||
if (callback) {
|
||||
return callback(await worker.recognize(image));
|
||||
}
|
||||
return await worker.recognize(image);
|
||||
}
|
||||
|
||||
export function parseResultMRZ(result: RecognizeResult) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue