2 changed files with 19 additions and 17 deletions
@ -1,19 +1,20 @@ |
|||||||
const workerUtils = require('../common/worker.js') |
const check = require('check-types'); |
||||||
|
const workerUtils = require('../common/worker'); |
||||||
|
|
||||||
process.on('message', function(packet){ |
let TesseractCore = null; |
||||||
workerUtils.dispatchHandlers(packet, obj => process.send(obj)) |
|
||||||
}) |
|
||||||
|
|
||||||
var TesseractCore; |
process.on('message', (packet) => { |
||||||
exports.getCore = function(req, res){ |
workerUtils.dispatchHandlers(packet, obj => process.send(obj)); |
||||||
if(!TesseractCore){ |
}); |
||||||
res.progress({ status: 'loading tesseract core' }) |
|
||||||
TesseractCore = require('tesseract.js-core') |
|
||||||
res.progress({ status: 'loaded tesseract core' }) |
|
||||||
} |
|
||||||
return TesseractCore |
|
||||||
} |
|
||||||
|
|
||||||
exports.getLanguageData = require('./lang.js') |
|
||||||
|
|
||||||
workerUtils.setAdapter(module.exports); |
workerUtils.setAdapter({ |
||||||
|
getCore: (req, res) => { |
||||||
|
if (check.null(TesseractCore)) { |
||||||
|
res.progress({ status: 'loading tesseract core' }); |
||||||
|
TesseractCore = require('tesseract.js-core'); |
||||||
|
res.progress({ status: 'loaded tesseract core' }); |
||||||
|
} |
||||||
|
return TesseractCore; |
||||||
|
}, |
||||||
|
getLanguageData: require('./lang'), |
||||||
|
}); |
||||||
|
Loading…
Reference in new issue