Add `fs.typeof` method
未關閉
good first issue
help wanted
- 主要語言
- TypeScript
- 星號
- 22
- 分支
- 1
- PR 合併指標
- 30 天內沒有已合併 PR
描述
It returns the path type according to its on-disk representation.
Possible results include: `file`, `directory`, `symlink`, `socket`, `fifo`, `characterDevice`, `blockDevice`
```ts
// The path argument may be absolute or relative to the root directory.
fs.typeof('foo')
```
The best use case for this is a `switch` statement.
```ts
switch (fs.typeof(path)) {
case 'file':
// ...
break
case 'directory':
// ...
break
default:
throw new Error('unsupported file type')
}
```
This is better than using `fs.stat` or `fs.lstat`, because `change` events don't need to be watched for like they do with those methods. Just need to use the `existenceWatcher`, I think.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。