崮生(子虚) fe61bace16 fix: 修复所有 TypeScript 类型错误
- 修复 fonteditor-core 模块声明(添加 FontEditor 命名空间、FontType 类型、SubsetOptions 接口)
- 修复 llrt.ts 中 mkdir 和 rm 方法的返回类型问题
- 修复 tcp_server.ts 中 chunk 类型问题(添加 Buffer 类型检查和转换)
- 修复 font_detail.ts 中缺失的 ORIGIN 导入
- 修复 subset.ts 中 subsetQueueTimeoutSeconds 的导入
- 为 Font 类添加 optimize() 和 write() 方法声明
2026-08-15 07:38:57 +08:00

32 lines
912 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import "web-streams-polyfill/polyfill";
import { implInterface } from "../interface";
import * as fs from "fs/promises";
/**
* LLRT 的 fs 适配层
*
* LLRT 的 fs.readdir 返回字符串数组,需要转换为 { name, isFile } 对象。
* LLRT 的 fs/promises 没有 unlink 方法implInterface 中会自动用 rm 代替。
*/
implInterface({
stat: fs.stat,
readFile: fs.readFile,
writeFile: fs.writeFile,
async readdir(path) {
const names = await fs.readdir(path);
return Promise.all(
names.map(async (name) => {
const s = await fs.stat(`${path}/${name}`);
return { name, isFile: () => s.isFile(), isDirectory: () => s.isDirectory() };
})
);
},
mkdir: async (path) => {
await fs.mkdir(path, { recursive: true });
},
/** LLRT 没有 unlink用 rm 代替,忽略返回值 */
rm: async (path: string) => {
await fs.rm(path);
},
});