Enables interacting with the file system
October 15, 2022 ยท View on GitHub
like nodejs, we can use by const fs = require('fs'), most file system operations have synchronous and promise-based forms
Api
fs module with following function
- statSync(path: string): statobj
- stat(path: string): Promise
- realpath (path: string): Promise
- realPathSync(path: string): string
- readFile(path: string): Promise<Buffer | string>
- readFileSync(path: string): Buffer | string
- writeFile(path: string, data: string | buffer): Promise
- writeFileSync(path: string, data: string | buffer): void
- unlink (path: string): Promise
- unlinkSync(path: string): void
- mkdir (path: string): Promise
- mkdirSync (path: string): void
- rmdir (path: string): Promise
- rmdirSync (path: string): void
statobj obj with following property
- isFile(): bool
- isDirectory(): bool
- isCharacterDevice(): bool
- isBlockDevice(): bool
- isFIFO(): bool
- isSocket(): bool
- isSymbolicLink(): bool
- dev
- info
- mode
- nlink
- uid
- gid
- rdev
- size
- blocks
- atime
- mtime
- ctime
- size