Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

now plantext works too

  • Loading branch information...
commit 35f96f284b2834732e2065e4dbee8687552ad6e1 1 parent b66884c
@KirillTemnov authored
Showing with 20 additions and 20 deletions.
  1. +19 −19 lib/app.coffee
  2. +1 −1  package.json
View
38 lib/app.coffee
@@ -19,7 +19,7 @@ Class that implement api calls to abbyy cloud api.
###
class OCR
constructor: (@appId=AppId, @appPass=AppPass) ->
- @version = "0.1.1"
+ @version = "0.1.2"
###
Create options, that passed to request object.
@@ -59,24 +59,24 @@ class OCR
@_createOptions parsedUrl.path, method, headers, port, parsedUrl.host
- ###
- Get binary data from server. This method is buggy.
+ # ###
+ # Get binary data from server. This method is buggy.
- @param {Object} opts Request options, @see _createOptionsFromUrl
- @param {Function} fn Callback function, that accept 1) error (or null) 2) data.
- ###
- _getServerBinaryAnswer: (opts, fn) ->
- resData = new Buffer 10485760
- ind = 0
- req = http.request opts, (res) ->
+ # @param {Object} opts Request options, @see _createOptionsFromUrl
+ # @param {Function} fn Callback function, that accept 1) error (or null) 2) data.
+ # ###
+ # _getServerBinaryAnswer: (opts, fn) ->
+ # resData = new Buffer 10485760
+ # ind = 0
+ # req = http.request opts, (res) ->
- res.setEncoding "binary"
- res.on "data", (chunk) ->
- ind += resData.write(chunk, ind)
- res.on "end", ->
- fn null, resData
- res.on "error", (err) -> fn err
- req.end()
+ # res.setEncoding "binary"
+ # res.on "data", (chunk) ->
+ # ind += resData.write(chunk, ind)
+ # res.on "end", ->
+ # fn null, resData
+ # res.on "error", (err) -> fn err
+ # req.end()
###
@@ -219,12 +219,12 @@ class OCR
getOpts = @_createOptionsFromUrl srcUrl, "GET", no
delete getOpts.headers.Authorization
- @_getServerBinaryAnswer getOpts, (err, data) ->
+ @_getServerAnswer getOpts, (err, data) ->
unless err
try
# conv = new iconv.Iconv "CP1251", "UTF8//IGNORE"
# text = conv.convert(data).toString()
- fn null, resultUrl: srcUrl, text: data #text
+ fn null, resultUrl: srcUrl, text: data#.toString() #text
catch e
fn msg: "error", resultUrl: srcUrl, error: e
else
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "node-ocr",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "wrapper for abbyy finereader cloud api (now in beta).",
"engines": {
"node": ">= 0.4.0 < 0.7.0"
Please sign in to comment.
Something went wrong with that request. Please try again.