Add `fs.typeof` method
- Linguagem predominante
- TypeScript
- Estrelas
- 22
- Forks
- 1
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.