-
读取文件状态
-
创建文件夹
-
连接文件
-
复制文件夹到指定位置,若文件夹已存在将被清空后进行复制操作
-
读取文件夹
-
递归清空文件夹,若文件夹不存在将被创建
-
递归清空文件夹
-
读取文件
-
写入文件
-
遍历文件夹
-
递归遍历文件
-
递归删除指定 extname 的文件
$ npm install @jiaminghi/fs
import { readFile } from '@jiaminghi/fs'
// do something
type stat = (
path: fs.PathLike,
options: fs.StatOptions = { bigint: false }
) => Promise<fs.Stats | fs.BigIntStats | false>
type mkDir = (path: fs.PathLike, options: fs.MakeDirectoryOptions = {}) => Promise<boolean>
type access = (path: fs.PathLike, mode = fs.constants.F_OK) => Promise<boolean>
type copyDir = (path: fs.PathLike, dest: string) => Promise<boolean>
type readDir = (path: fs.PathLike) => Promise<string[] | false>
type clearDir = (path: fs.PathLike) => Promise<boolean>
type emptyDir = (path: fs.PathLike) => Promise<boolean>
type readFile = (
path: fs.PathLike,
options: { encoding: string; flag?: string } = { encoding: 'utf8' }
) => Promise<string | false>
type writeFile = (
path: fs.PathLike,
data: any,
option: fs.WriteFileOptions = 'utf8'
) => Promise<boolean>
type dirForEach = (path: fs.PathLike, callback: (path: string) => any) => Promise<boolean>
type fileForEach = (path: fs.PathLike, callback: (path: string) => any) => Promise<boolean>
type unlinkDirFileByExtname = (path: fs.PathLike, extnames: string[] = []) => Promise<boolean>