ocr-space-api-wrapper 2.4.3 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +2 -2
- package/test/test.js +8 -0
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ The input param specifies the input file (see examples above). It can be _one_ o
|
|
|
39
39
|
This param is an object with the following keys:
|
|
40
40
|
- `apiKey`: your API key for [ocr.space APIs](https://ocr.space/ocrapi). Default API key has a limit of max 10reqs in 10mins.
|
|
41
41
|
- `ocrUrl`: a different URL for ocr.space APIs, for example when you purchase the PRO plan.
|
|
42
|
+
- `signal`: an `AbortSignal` for `AbortController` to abort the request.
|
|
42
43
|
- All other params as documented in the [official website](https://ocr.space/OCRAPI#PostParameters).
|
|
43
44
|
|
|
44
45
|
## Response
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -28,6 +28,7 @@ async function ocrSpace(input, options = {}) {
|
|
|
28
28
|
apiKey, ocrUrl, language, isOverlayRequired,
|
|
29
29
|
filetype, detectOrientation, isCreateSearchablePdf,
|
|
30
30
|
isSearchablePdfHideTextLayer, scale, isTable, OCREngine,
|
|
31
|
+
signal,
|
|
31
32
|
} = options;
|
|
32
33
|
const formData = new FormData();
|
|
33
34
|
const detectedInput = detectInput(input);
|
|
@@ -66,6 +67,7 @@ async function ocrSpace(input, options = {}) {
|
|
|
66
67
|
data: formData,
|
|
67
68
|
maxContentLength: Infinity,
|
|
68
69
|
maxBodyLength: Infinity,
|
|
70
|
+
signal,
|
|
69
71
|
};
|
|
70
72
|
const { data } = await axios(request);
|
|
71
73
|
return data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ocr-space-api-wrapper",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"description": "Node.js wrapper for ocr.space APIs.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/DavideViolante/ocr-space-api-wrapper#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"axios": "~0.30.
|
|
34
|
+
"axios": "~0.30.3",
|
|
35
35
|
"form-data": "^4.0.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
package/test/test.js
CHANGED
|
@@ -76,4 +76,12 @@ describe('Tests for OCR Space API Wrapper', () => {
|
|
|
76
76
|
assert.notStrictEqual(res1.SearchablePDFURL, 'Searchable PDF not generated as it was not requested.');
|
|
77
77
|
assert.match(res1.SearchablePDFURL, /https?:\/\/.*\.pdf/);
|
|
78
78
|
});
|
|
79
|
+
it('should abort the request', async () => {
|
|
80
|
+
const controller = new AbortController();
|
|
81
|
+
const { signal } = controller;
|
|
82
|
+
const promise = ocrSpace('./test/eng.png', { signal });
|
|
83
|
+
controller.abort();
|
|
84
|
+
const res1 = await promise;
|
|
85
|
+
assert.strictEqual(res1, undefined);
|
|
86
|
+
});
|
|
79
87
|
});
|