officeparser 5.2.0 → 5.2.1
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/officeParser.js +2 -4
- package/package.json +1 -1
- package/typings/officeParser.d.ts +7 -7
package/officeParser.js
CHANGED
|
@@ -8,9 +8,6 @@ const fileType = require('file-type');
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const yauzl = require('yauzl');
|
|
10
10
|
|
|
11
|
-
/** Load pdfjs-dist once at module scope. This returns a Promise that resolves to the module. */
|
|
12
|
-
const pdfjsPromise = import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
13
|
-
|
|
14
11
|
/** Header for error messages */
|
|
15
12
|
const ERRORHEADER = "[OfficeParser]: ";
|
|
16
13
|
/** Error messages */
|
|
@@ -450,7 +447,8 @@ function parseOpenOffice(file, callback, config) {
|
|
|
450
447
|
*/
|
|
451
448
|
async function parsePdf(file, callback, config) {
|
|
452
449
|
// Wait for pdfjs module to be loaded once
|
|
453
|
-
|
|
450
|
+
// Lazy import pdfjs to avoid Node startup issues for environments that don't use PDF parsing
|
|
451
|
+
const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
454
452
|
|
|
455
453
|
// Get the pdfjs document for the filepath or Uint8Array buffers.
|
|
456
454
|
// pdfjs does not accept Buffers directly, so we convert them to Uint8Array.
|
package/package.json
CHANGED
|
@@ -18,16 +18,16 @@ export type OfficeParserConfig = {
|
|
|
18
18
|
putNotesAtLast?: boolean;
|
|
19
19
|
};
|
|
20
20
|
/** Main async function with callback to execute parseOffice for supported files
|
|
21
|
-
* @param {string | Buffer}
|
|
22
|
-
* @param {function}
|
|
23
|
-
* @param {OfficeParserConfig}
|
|
21
|
+
* @param {string | Buffer | ArrayBuffer} srcFile File path or file buffers or Javascript ArrayBuffer
|
|
22
|
+
* @param {function} callback Callback function that returns value or error
|
|
23
|
+
* @param {OfficeParserConfig} [config={}] [OPTIONAL]: Config Object for officeParser
|
|
24
24
|
* @returns {void}
|
|
25
25
|
*/
|
|
26
|
-
export function parseOffice(
|
|
26
|
+
export function parseOffice(srcFile: string | Buffer | ArrayBuffer, callback: Function, config?: OfficeParserConfig): void;
|
|
27
27
|
/** Main async function that can be used with await to execute parseOffice. Or it can be used with promises.
|
|
28
|
-
* @param {string | Buffer}
|
|
29
|
-
* @param {OfficeParserConfig}
|
|
28
|
+
* @param {string | Buffer | ArrayBuffer} srcFile File path or file buffers or Javascript ArrayBuffer
|
|
29
|
+
* @param {OfficeParserConfig} [config={}] [OPTIONAL]: Config Object for officeParser
|
|
30
30
|
* @returns {Promise<string>}
|
|
31
31
|
*/
|
|
32
|
-
export function parseOfficeAsync(
|
|
32
|
+
export function parseOfficeAsync(srcFile: string | Buffer | ArrayBuffer, config?: OfficeParserConfig): Promise<string>;
|
|
33
33
|
//# sourceMappingURL=officeParser.d.ts.map
|