(file: string, encoding?: BufferEncoding)
| 74 | export function readRegularFileSync(file: string): Buffer; |
| 75 | export function readRegularFileSync(file: string, encoding: BufferEncoding): string; |
| 76 | export function readRegularFileSync(file: string, encoding?: BufferEncoding): string | Buffer { |
| 77 | const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0)); |
| 78 | try { |
| 79 | if (!fs.fstatSync(fd).isFile()) throw notRegularFile(file); |
| 80 | return encoding ? fs.readFileSync(fd, encoding) : fs.readFileSync(fd); |
| 81 | } finally { |
| 82 | fs.closeSync(fd); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * `fs.writeFileSync` for the same kind of name: it replaces a regular file's |
no test coverage detected