perf: async read file (#4978)

* perf: async read file

* package

* doc
This commit is contained in:
Archer
2025-06-08 18:46:36 +08:00
committed by GitHub
parent 188008255d
commit 7494ce8453
9 changed files with 36 additions and 32 deletions

View File

@@ -4,7 +4,7 @@ import { readFileRawText } from './rawText';
// 加载源文件内容
export const readCsvRawText = async (params: ReadRawTextByBuffer): Promise<ReadFileResponse> => {
const { rawText } = readFileRawText(params);
const { rawText } = await readFileRawText(params);
const csvArr = Papa.parse(rawText).data as string[][];

View File

@@ -3,7 +3,7 @@ import { readFileRawText } from './rawText';
import { html2md } from '../../htmlStr2Md/utils';
export const readHtmlRawText = async (params: ReadRawTextByBuffer): Promise<ReadFileResponse> => {
const { rawText: html } = readFileRawText(params);
const { rawText: html } = await readFileRawText(params);
const { rawText, imageList } = html2md(html);

View File

@@ -18,7 +18,10 @@ const rawEncodingList = [
];
// 加载源文件内容
export const readFileRawText = ({ buffer, encoding }: ReadRawTextByBuffer): ReadFileResponse => {
export const readFileRawText = async ({
buffer,
encoding
}: ReadRawTextByBuffer): Promise<ReadFileResponse> => {
const content = (() => {
try {
if (rawEncodingList.includes(encoding)) {