diff --git a/src/utils/io/read-file-options.ts b/src/utils/io/read-file-options.ts new file mode 100644 index 0000000..eb04f04 --- /dev/null +++ b/src/utils/io/read-file-options.ts @@ -0,0 +1,32 @@ +import { readFileSync } from "node:fs"; +import { readFile } from "node:fs/promises"; + +/** + * Options that can be used with `fs.readFile()` to read a file asynchronously. + */ +export type AsyncReadFileOptions = Parameters[1]; + +/** + * Options that can be used with `fs.readFileSync()` to read a file synchronously. + */ +export type SyncReadFileOptions = Parameters[1]; + +/** + * All possible options that can be passed to `fs.readFile()` and `fs.readFileSync()`. + */ +export type ReadFileOptions = AsyncReadFileOptions | SyncReadFileOptions; + +/** + * Object-style options that can be used with `fs.readFile()` to read a file asynchronously. + */ +export type AsyncReadFileOptionsObject = Exclude; + +/** + * Object-style options that can be used with `fs.readFileSync()` to read a file synchronously. + */ +export type SyncReadFileOptionsObject = Exclude; + +/** + * All possible object-style options that can be passed to `fs.readFile()` and `fs.readFileSync()`. + */ +export type ReadFileOptionsObject = AsyncReadFileOptionsObject | SyncReadFileOptionsObject;