Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reworked createWorker to be async and throw errors per #654
  • Loading branch information
Balearica committed Sep 17, 2022
1 parent 0277db2 commit b87afe9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions examples/node/benchmark.js
Expand Up @@ -2,10 +2,8 @@
const path = require('path');
const { createWorker } = require('../../');

const worker = createWorker();

(async () => {
await worker.load();
const worker = await createWorker();
await worker.loadLanguage('eng');
await worker.initialize('eng');
const fileArr = ["../data/meditations.jpg", "../data/tyger.jpg", "../data/testocr.png"];
Expand Down
3 changes: 1 addition & 2 deletions examples/node/download-pdf.js
Expand Up @@ -9,8 +9,7 @@ const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/c
console.log(`Recognizing ${image}`);

(async () => {
const worker = createWorker();
await worker.load();
const worker = await createWorker();
await worker.loadLanguage('eng');
await worker.initialize('eng');
const { data: { text } } = await worker.recognize(image);
Expand Down
7 changes: 3 additions & 4 deletions examples/node/recognize.js
Expand Up @@ -6,12 +6,11 @@ const [,, imagePath] = process.argv;
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png'));

console.log(`Recognizing ${image}`);
const worker = createWorker({
logger: m => console.log(m),
});

(async () => {
await worker.load();
const worker = await createWorker({
logger: m => console.log(m),
});
await worker.loadLanguage('eng');
await worker.initialize('eng');
const { data: { text } } = await worker.recognize(image);
Expand Down

0 comments on commit b87afe9

Please sign in to comment.