Browse Source

Fix lint error

feature/aio
Jerome Wu 6 years ago
parent
commit
080151711b
  1. 6
      .eslintrc
  2. 34
      package-lock.json
  3. 1
      package.json
  4. 4
      src/browser/index.js
  5. 4
      src/browser/worker.js
  6. 7
      src/common/workerUtils.js

6
.eslintrc

@ -3,11 +3,13 @@
"env": { "env": {
"browser": true, "browser": true,
"node": true, "node": true,
"mocha": true "mocha": true,
"worker": true
}, },
"rules": { "rules": {
"no-underscore-dangle": 0, "no-underscore-dangle": 0,
"no-console": 0, "no-console": 0,
"global-require": 0 "global-require": 0,
"camelcase": 0
} }
} }

34
package-lock.json generated

@ -381,6 +381,12 @@
"negotiator": "0.6.1" "negotiator": "0.6.1"
} }
}, },
"acorn": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
"integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
"dev": true
},
"acorn-dynamic-import": { "acorn-dynamic-import": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz",
@ -2549,14 +2555,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2571,20 +2575,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2701,8 +2702,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2714,7 +2714,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2729,7 +2728,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2737,14 +2735,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2763,7 +2759,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2844,8 +2839,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2857,7 +2851,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2979,7 +2972,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",

1
package.json

@ -25,6 +25,7 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"acorn": "^6.1.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"eslint": "^5.9.0", "eslint": "^5.9.0",
"eslint-config-airbnb": "^17.1.0", "eslint-config-airbnb": "^17.1.0",

4
src/browser/index.js

@ -39,7 +39,7 @@ const readFromBlobOrFile = (blob, res) => {
* string: URL string, can be relative path * string: URL string, can be relative path
* img HTMLElement: extract image source from src attribute * img HTMLElement: extract image source from src attribute
* video HTMLElement: extract image source from poster attribute * video HTMLElement: extract image source from poster attribute
* canvas HTMLElement: extract image data by converting to Blob * canvas HTMLElement: extract image data by converting to Blob
* File instance: data from <input type="file" /> * File instance: data from <input type="file" />
* @returns {array} binary image in array format * @returns {array} binary image in array format
*/ */
@ -88,7 +88,7 @@ const downloadFile = (path, blob) => {
document.body.removeChild(link); document.body.removeChild(link);
} }
} }
} };
/* /*
* Default options for browser worker * Default options for browser worker

4
src/browser/worker.js

@ -33,7 +33,7 @@ workerUtils.setAdapter({
*/ */
if (check.not.undefined(global.TesseractCoreWASM) && typeof WebAssembly === 'object') { if (check.not.undefined(global.TesseractCoreWASM) && typeof WebAssembly === 'object') {
global.TesseractCore = global.TesseractCoreWASM; global.TesseractCore = global.TesseractCoreWASM;
} else if (check.not.undefined(global.TesseractCoreASM)){ } else if (check.not.undefined(global.TesseractCoreASM)) {
global.TesseractCore = global.TesseractCoreASM; global.TesseractCore = global.TesseractCoreASM;
} else { } else {
throw Error('Failed to load TesseractCore'); throw Error('Failed to load TesseractCore');
@ -44,7 +44,7 @@ workerUtils.setAdapter({
}, },
b64toU8Array: s => new Uint8Array(atob(s).split('').map(c => c.charCodeAt(0))), b64toU8Array: s => new Uint8Array(atob(s).split('').map(c => c.charCodeAt(0))),
writeFile: (path, data, type) => { writeFile: (path, data, type) => {
self.postMessage({ postMessage({
jobId: 'Download', jobId: 'Download',
path, path,
data, data,

7
src/common/workerUtils.js

@ -8,7 +8,6 @@
* @author Jerome Wu <jeromewus@gmail.com> * @author Jerome Wu <jeromewus@gmail.com>
*/ */
const { readImage, loadLang } = require('tesseract.js-utils'); const { readImage, loadLang } = require('tesseract.js-utils');
const check = require('check-types');
const pdfTTF = require('./pdf-ttf'); const pdfTTF = require('./pdf-ttf');
const dump = require('./dump'); const dump = require('./dump');
const { defaultParams } = require('./options'); const { defaultParams } = require('./options');
@ -59,7 +58,7 @@ const setImage = (image) => {
* @name handleParams * @name handleParams
* @function hanlde params from users * @function hanlde params from users
* @access private * @access private
* @param {string} lang - lang string for Init() * @param {string} lang - lang string for Init()
* @param {object} customParams - an object of params * @param {object} customParams - an object of params
*/ */
const handleParams = (lang, customParams) => { const handleParams = (lang, customParams) => {
@ -110,14 +109,14 @@ const handleOutput = (customParams) => {
if (pdf_bin) { if (pdf_bin) {
files = { pdf: data, ...files }; files = { pdf: data, ...files };
} }
if (pdf_auto_download) { if (pdf_auto_download) {
adapter.writeFile(`${pdf_name}.pdf`, data, 'application/pdf'); adapter.writeFile(`${pdf_name}.pdf`, data, 'application/pdf');
} }
} }
return files; return files;
} };
/** /**
* handleInit * handleInit

Loading…
Cancel
Save