Add `fs.typeof` method
- Ngôn ngữ chính
- TypeScript
- Star
- 22
- Fork
- 1
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.