File tree 9 files changed +23
-10
lines changed
9 files changed +23
-10
lines changed Original file line number Diff line number Diff line change 44
44
"test" : " run-s test:compile test:integration" ,
45
45
"test:compile" : " tsc --noEmit" ,
46
46
"test:quality" : " xo source/ test/" ,
47
- "test:integration" : " ava"
47
+ "test:integration" : " TSIMP_DIAG=ignore ava"
48
48
},
49
49
"dependencies" : {
50
+ "buffer" : " 6.0.3" ,
50
51
"fflate" : " 0.8.2" ,
51
52
"file-type" : " 19.3.0" ,
52
53
"got" : " 14.4.1" ,
Original file line number Diff line number Diff line change 1
1
// source/lib.ts
2
2
// The source code for the library.
3
3
4
- import { Buffer } from 'node: buffer'
4
+ import { Buffer } from 'buffer/index.js '
5
5
import { fileTypeFromBuffer as getFileType } from 'file-type'
6
6
import { readFile , fetchUrl } from './util.js'
7
7
Original file line number Diff line number Diff line change 1
1
// source/parsers/docx.ts
2
2
// The text extracter for DOCX files.
3
3
4
- import { type Buffer } from 'node: buffer'
4
+ import { type Buffer } from 'buffer/ '
5
5
import { extractRawText as parseWordFile } from 'mammoth'
6
6
7
7
import type { TextExtractionMethod } from '../lib.js'
@@ -22,6 +22,7 @@ export class DocExtractor implements TextExtractionMethod {
22
22
*/
23
23
apply = async ( input : Buffer ) : Promise < string > => {
24
24
// Convert the DOCX to text and return the text.
25
+ // @ts -expect-error: see feross/buffer#353, the types are incomplete.
25
26
const parsedDocx = await parseWordFile ( { buffer : input } )
26
27
return parsedDocx . value
27
28
}
Original file line number Diff line number Diff line change 1
1
// source/parsers/excel.ts
2
2
// The text extracter for Excel files.
3
3
4
- import { type Buffer } from 'node: buffer'
4
+ import { type Buffer } from 'buffer/ '
5
5
import Xlsx , { utils as sheetUtils } from 'xlsx'
6
6
import { dump as convertToYaml } from 'js-yaml'
7
7
Original file line number Diff line number Diff line change 1
1
// source/parsers/pdf.ts
2
2
// The text extracter for PDF files.
3
3
4
- import { type Buffer } from 'node: buffer'
4
+ import { type Buffer } from 'buffer/ '
5
5
// @ts -expect-error There are no types for this package.
6
6
import parsePdf from 'pdf-parse/lib/pdf-parse.js'
7
7
Original file line number Diff line number Diff line change 3
3
4
4
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
5
6
- import { type Buffer } from 'node: buffer'
6
+ import { type Buffer } from 'buffer/ '
7
7
import { unzip } from 'fflate'
8
8
import { parseStringPromise as xmlToJson } from 'xml2js'
9
9
import encoding from 'text-encoding'
Original file line number Diff line number Diff line change 1
1
// source/util.ts
2
2
// Utility functions to help with the handling of input.
3
3
4
- import { type Buffer } from 'node:buffer'
5
4
import { readFile as read } from 'node:fs/promises'
6
5
import { got as fetch } from 'got'
6
+ import { type Buffer } from 'buffer/'
7
7
8
8
export const readFile = async ( filePath : string ) : Promise < Buffer > =>
9
- read ( filePath )
9
+ ( await read ( filePath ) ) as unknown as Buffer
10
10
export const fetchUrl = async ( url : string ) : Promise < Buffer > =>
11
- fetch ( url ) . buffer ( )
11
+ ( await fetch ( url ) . buffer ( ) ) as unknown as Buffer
Original file line number Diff line number Diff line change 2
2
// This file contains the integration test for the library.
3
3
4
4
import { readFileSync } from 'node:fs'
5
- import { type Buffer } from 'node:buffer'
6
5
import test from 'ava'
7
6
7
+ import { type Buffer } from 'buffer/'
8
8
import { getTextExtractor , type InputType } from '../../source/index.js'
9
9
10
10
const extractor = getTextExtractor ( )
You can’t perform that action at this time.
0 commit comments