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 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
- const pdfjs = await pdfjsPromise;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "officeparser",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "description": "A Node.js library to parse text out of any office file. Currently supports docx, pptx, xlsx, odt, odp, ods, pdf files.",
5
5
  "main": "officeParser.js",
6
6
  "files": [
@@ -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} file File path or file buffers
22
- * @param {function} callback Callback function that returns value or error
23
- * @param {OfficeParserConfig} [config={}] [OPTIONAL]: Config Object for officeParser
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(file: string | Buffer, callback: Function, config?: OfficeParserConfig): void;
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} file File path or file buffers
29
- * @param {OfficeParserConfig} [config={}] [OPTIONAL]: Config Object for officeParser
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(file: string | Buffer, config?: OfficeParserConfig): Promise<string>;
32
+ export function parseOfficeAsync(srcFile: string | Buffer | ArrayBuffer, config?: OfficeParserConfig): Promise<string>;
33
33
  //# sourceMappingURL=officeParser.d.ts.map