Browse Source

Fixed syntax error

and added process.exit() to the examples
pull/39/head
Kiran Kota 8 years ago
parent
commit
07ba35171f
  1. 6
      dist/tesseract.js
  2. 130
      dist/worker.js
  3. 1
      examples/node/basic.js
  4. 5
      examples/node/detect.js
  5. 4
      src/node/index.js

6
dist/tesseract.js vendored

@ -288,11 +288,13 @@ module.exports={ @@ -288,11 +288,13 @@ module.exports={
"browserify": "^13.1.0",
"envify": "^3.4.1",
"http-server": "^0.9.0",
"watchify": "^3.7.0",
"pako": "^1.0.3"
"pako": "^1.0.3",
"watchify": "^3.7.0"
},
"dependencies": {
"file-type": "^3.8.0",
"is-url": "^1.2.2",
"isomorphic-fetch": "^2.2.1",
"jpeg-js": "^0.2.0",
"level-js": "^2.2.4",
"object-assign": "^4.1.0",

130
dist/worker.js vendored

@ -82,7 +82,7 @@ AbstractChainedBatch.prototype.write = function (options, callback) { @@ -82,7 +82,7 @@ AbstractChainedBatch.prototype.write = function (options, callback) {
module.exports = AbstractChainedBatch
}).call(this,require('_process'))
},{"_process":33}],2:[function(require,module,exports){
},{"_process":31}],2:[function(require,module,exports){
(function (process){
/* Copyright (c) 2013 Rod Vagg, MIT License */
@ -135,7 +135,7 @@ AbstractIterator.prototype.end = function (callback) { @@ -135,7 +135,7 @@ AbstractIterator.prototype.end = function (callback) {
module.exports = AbstractIterator
}).call(this,require('_process'))
},{"_process":33}],3:[function(require,module,exports){
},{"_process":31}],3:[function(require,module,exports){
(function (Buffer,process){
/* Copyright (c) 2013 Rod Vagg, MIT License */
@ -395,7 +395,7 @@ module.exports.AbstractIterator = AbstractIterator @@ -395,7 +395,7 @@ module.exports.AbstractIterator = AbstractIterator
module.exports.AbstractChainedBatch = AbstractChainedBatch
}).call(this,{"isBuffer":require("../is-buffer/index.js")},require('_process'))
},{"../is-buffer/index.js":9,"./abstract-chained-batch":1,"./abstract-iterator":2,"_process":33,"xtend":4}],4:[function(require,module,exports){
},{"../is-buffer/index.js":9,"./abstract-chained-batch":1,"./abstract-iterator":2,"_process":31,"xtend":4}],4:[function(require,module,exports){
module.exports = extend
function extend() {
@ -4034,7 +4034,7 @@ var checkKeyValue = Level.prototype._checkKeyValue = function (obj, type) { @@ -4034,7 +4034,7 @@ var checkKeyValue = Level.prototype._checkKeyValue = function (obj, type) {
}
}).call(this,require("buffer").Buffer)
},{"./iterator":13,"abstract-leveldown":3,"buffer":6,"idb-wrapper":7,"isbuffer":11,"typedarray-to-buffer":34,"util":37,"xtend":15}],13:[function(require,module,exports){
},{"./iterator":13,"abstract-leveldown":3,"buffer":6,"idb-wrapper":7,"isbuffer":11,"typedarray-to-buffer":32,"util":35,"xtend":37}],13:[function(require,module,exports){
var util = require('util')
var AbstractIterator = require('abstract-leveldown').AbstractIterator
var ltgt = require('ltgt')
@ -4108,43 +4108,7 @@ Iterator.prototype._next = function (callback) { @@ -4108,43 +4108,7 @@ Iterator.prototype._next = function (callback) {
this.callback = callback
}
},{"abstract-leveldown":3,"ltgt":16,"util":37}],14:[function(require,module,exports){
module.exports = hasKeys
function hasKeys(source) {
return source !== null &&
(typeof source === "object" ||
typeof source === "function")
}
},{}],15:[function(require,module,exports){
var Keys = require("object-keys")
var hasKeys = require("./has-keys")
module.exports = extend
function extend() {
var target = {}
for (var i = 0; i < arguments.length; i++) {
var source = arguments[i]
if (!hasKeys(source)) {
continue
}
var keys = Keys(source)
for (var j = 0; j < keys.length; j++) {
var name = keys[j]
target[name] = source[name]
}
}
return target
}
},{"./has-keys":14,"object-keys":18}],16:[function(require,module,exports){
},{"abstract-leveldown":3,"ltgt":14,"util":35}],14:[function(require,module,exports){
(function (Buffer){
exports.compare = function (a, b) {
@ -4294,7 +4258,7 @@ exports.filter = function (range, compare) { @@ -4294,7 +4258,7 @@ exports.filter = function (range, compare) {
}
}).call(this,{"isBuffer":require("../is-buffer/index.js")})
},{"../is-buffer/index.js":9}],17:[function(require,module,exports){
},{"../is-buffer/index.js":9}],15:[function(require,module,exports){
var hasOwn = Object.prototype.hasOwnProperty;
var toString = Object.prototype.toString;
@ -4336,11 +4300,11 @@ module.exports = function forEach(obj, fn) { @@ -4336,11 +4300,11 @@ module.exports = function forEach(obj, fn) {
};
},{}],18:[function(require,module,exports){
},{}],16:[function(require,module,exports){
module.exports = Object.keys || require('./shim');
},{"./shim":20}],19:[function(require,module,exports){
},{"./shim":18}],17:[function(require,module,exports){
var toString = Object.prototype.toString;
module.exports = function isArguments(value) {
@ -4358,7 +4322,7 @@ module.exports = function isArguments(value) { @@ -4358,7 +4322,7 @@ module.exports = function isArguments(value) {
};
},{}],20:[function(require,module,exports){
},{}],18:[function(require,module,exports){
(function () {
"use strict";
@ -4422,7 +4386,7 @@ module.exports = function isArguments(value) { @@ -4422,7 +4386,7 @@ module.exports = function isArguments(value) {
}());
},{"./foreach":17,"./isArguments":19}],21:[function(require,module,exports){
},{"./foreach":15,"./isArguments":17}],19:[function(require,module,exports){
'use strict';
@ -4842,7 +4806,7 @@ exports.inflate = inflate; @@ -4842,7 +4806,7 @@ exports.inflate = inflate;
exports.inflateRaw = inflateRaw;
exports.ungzip = inflate;
},{"./utils/common":22,"./utils/strings":23,"./zlib/constants":25,"./zlib/gzheader":27,"./zlib/inflate":29,"./zlib/messages":31,"./zlib/zstream":32}],22:[function(require,module,exports){
},{"./utils/common":20,"./utils/strings":21,"./zlib/constants":23,"./zlib/gzheader":25,"./zlib/inflate":27,"./zlib/messages":29,"./zlib/zstream":30}],20:[function(require,module,exports){
'use strict';
@ -4946,7 +4910,7 @@ exports.setTyped = function (on) { @@ -4946,7 +4910,7 @@ exports.setTyped = function (on) {
exports.setTyped(TYPED_OK);
},{}],23:[function(require,module,exports){
},{}],21:[function(require,module,exports){
// String encode/decode helpers
'use strict';
@ -5133,7 +5097,7 @@ exports.utf8border = function (buf, max) { @@ -5133,7 +5097,7 @@ exports.utf8border = function (buf, max) {
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
};
},{"./common":22}],24:[function(require,module,exports){
},{"./common":20}],22:[function(require,module,exports){
'use strict';
// Note: adler32 takes 12% for level 0 and 2% for level 6.
@ -5167,7 +5131,7 @@ function adler32(adler, buf, len, pos) { @@ -5167,7 +5131,7 @@ function adler32(adler, buf, len, pos) {
module.exports = adler32;
},{}],25:[function(require,module,exports){
},{}],23:[function(require,module,exports){
'use strict';
@ -5219,7 +5183,7 @@ module.exports = { @@ -5219,7 +5183,7 @@ module.exports = {
//Z_NULL: null // Use -1 or null inline, depending on var type
};
},{}],26:[function(require,module,exports){
},{}],24:[function(require,module,exports){
'use strict';
// Note: we can't get significant speed boost here.
@ -5262,7 +5226,7 @@ function crc32(crc, buf, len, pos) { @@ -5262,7 +5226,7 @@ function crc32(crc, buf, len, pos) {
module.exports = crc32;
},{}],27:[function(require,module,exports){
},{}],25:[function(require,module,exports){
'use strict';
@ -5304,7 +5268,7 @@ function GZheader() { @@ -5304,7 +5268,7 @@ function GZheader() {
module.exports = GZheader;
},{}],28:[function(require,module,exports){
},{}],26:[function(require,module,exports){
'use strict';
// See state defs from inflate.js
@ -5632,7 +5596,7 @@ module.exports = function inflate_fast(strm, start) { @@ -5632,7 +5596,7 @@ module.exports = function inflate_fast(strm, start) {
return;
};
},{}],29:[function(require,module,exports){
},{}],27:[function(require,module,exports){
'use strict';
@ -7172,7 +7136,7 @@ exports.inflateSyncPoint = inflateSyncPoint; @@ -7172,7 +7136,7 @@ exports.inflateSyncPoint = inflateSyncPoint;
exports.inflateUndermine = inflateUndermine;
*/
},{"../utils/common":22,"./adler32":24,"./crc32":26,"./inffast":28,"./inftrees":30}],30:[function(require,module,exports){
},{"../utils/common":20,"./adler32":22,"./crc32":24,"./inffast":26,"./inftrees":28}],28:[function(require,module,exports){
'use strict';
@ -7501,7 +7465,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta @@ -7501,7 +7465,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
return 0;
};
},{"../utils/common":22}],31:[function(require,module,exports){
},{"../utils/common":20}],29:[function(require,module,exports){
'use strict';
module.exports = {
@ -7516,7 +7480,7 @@ module.exports = { @@ -7516,7 +7480,7 @@ module.exports = {
'-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
};
},{}],32:[function(require,module,exports){
},{}],30:[function(require,module,exports){
'use strict';
@ -7547,7 +7511,7 @@ function ZStream() { @@ -7547,7 +7511,7 @@ function ZStream() {
module.exports = ZStream;
},{}],33:[function(require,module,exports){
},{}],31:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
@ -7729,7 +7693,7 @@ process.chdir = function (dir) { @@ -7729,7 +7693,7 @@ process.chdir = function (dir) {
};
process.umask = function() { return 0; };
},{}],34:[function(require,module,exports){
},{}],32:[function(require,module,exports){
(function (Buffer){
/**
* Convert a typed array to a Buffer without a copy
@ -7752,7 +7716,7 @@ module.exports = function (arr) { @@ -7752,7 +7716,7 @@ module.exports = function (arr) {
}
}).call(this,require("buffer").Buffer)
},{"buffer":6}],35:[function(require,module,exports){
},{"buffer":6}],33:[function(require,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
@ -7777,14 +7741,14 @@ if (typeof Object.create === 'function') { @@ -7777,14 +7741,14 @@ if (typeof Object.create === 'function') {
}
}
},{}],36:[function(require,module,exports){
},{}],34:[function(require,module,exports){
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
},{}],37:[function(require,module,exports){
},{}],35:[function(require,module,exports){
(function (process,global){
// Copyright Joyent, Inc. and other Node contributors.
//
@ -8374,7 +8338,43 @@ function hasOwnProperty(obj, prop) { @@ -8374,7 +8338,43 @@ function hasOwnProperty(obj, prop) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./support/isBuffer":36,"_process":33,"inherits":35}],38:[function(require,module,exports){
},{"./support/isBuffer":34,"_process":31,"inherits":33}],36:[function(require,module,exports){
module.exports = hasKeys
function hasKeys(source) {
return source !== null &&
(typeof source === "object" ||
typeof source === "function")
}
},{}],37:[function(require,module,exports){
var Keys = require("object-keys")
var hasKeys = require("./has-keys")
module.exports = extend
function extend() {
var target = {}
for (var i = 0; i < arguments.length; i++) {
var source = arguments[i]
if (!hasKeys(source)) {
continue
}
var keys = Keys(source)
for (var j = 0; j < keys.length; j++) {
var name = keys[j]
target[name] = source[name]
}
}
return target
}
},{"./has-keys":36,"object-keys":16}],38:[function(require,module,exports){
'use strict';
var leveljs = require('level-js');
@ -8458,7 +8458,7 @@ function fetchLanguageData(req, res, cb) { @@ -8458,7 +8458,7 @@ function fetchLanguageData(req, res, cb) {
xhr.send();
}
},{"../common/langdata.json":42,"level-js":12,"pako/lib/inflate.js":21}],39:[function(require,module,exports){
},{"../common/langdata.json":42,"level-js":12,"pako/lib/inflate.js":19}],39:[function(require,module,exports){
(function (process,global){
'use strict';
@ -8489,7 +8489,7 @@ exports.getLanguageData = require('./lang.js'); @@ -8489,7 +8489,7 @@ exports.getLanguageData = require('./lang.js');
workerUtils.setAdapter(module.exports);
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../common/worker.js":43,"./lang.js":38,"_process":33}],40:[function(require,module,exports){
},{"../common/worker.js":43,"./lang.js":38,"_process":31}],40:[function(require,module,exports){
'use strict';
// This converts an image to grayscale

1
examples/node/basic.js

@ -11,4 +11,5 @@ Tesseract.recognize(image) @@ -11,4 +11,5 @@ Tesseract.recognize(image)
})
.finally(e => {
console.log('finally\n');
process.exit();
});

5
examples/node/detect.js

@ -4,8 +4,9 @@ var image = path.resolve(__dirname, 'cosmic.png'); @@ -4,8 +4,9 @@ var image = path.resolve(__dirname, 'cosmic.png');
Tesseract.detect(image)
.progress(function(info){
console.log(info)
console.log(info);
})
.then(function(data){
console.log('done', data)
console.log('done', data);
process.exit();
})

4
src/node/index.js

@ -32,7 +32,7 @@ exports.sendPacket = function sendPacket(instance, packet){ @@ -32,7 +32,7 @@ exports.sendPacket = function sendPacket(instance, packet){
function loadImage(image, cb){
if(isURL(image) {
if(isURL(image)) {
fetch(image).then(function (resp) {
return resp.buffer();
}).then(function (buffer) {
@ -40,7 +40,7 @@ function loadImage(image, cb){ @@ -40,7 +40,7 @@ function loadImage(image, cb){
}).catch(function (err) {
return console.error(err);
});
})
}
if(typeof image === 'string'){
fs.readFile(image, function(err, buffer){

Loading…
Cancel
Save