mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2025-02-02 07:04:44 +01:00
Made a few utility types for readFile
options
This commit is contained in:
parent
49ccf5b5a2
commit
88b6d0607a
1 changed files with 32 additions and 0 deletions
32
src/utils/io/read-file-options.ts
Normal file
32
src/utils/io/read-file-options.ts
Normal file
|
@ -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<typeof readFile>[1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options that can be used with `fs.readFileSync()` to read a file synchronously.
|
||||||
|
*/
|
||||||
|
export type SyncReadFileOptions = Parameters<typeof readFileSync>[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<AsyncReadFileOptions, string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object-style options that can be used with `fs.readFileSync()` to read a file synchronously.
|
||||||
|
*/
|
||||||
|
export type SyncReadFileOptionsObject = Exclude<SyncReadFileOptions, string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All possible object-style options that can be passed to `fs.readFile()` and `fs.readFileSync()`.
|
||||||
|
*/
|
||||||
|
export type ReadFileOptionsObject = AsyncReadFileOptionsObject | SyncReadFileOptionsObject;
|
Loading…
Reference in a new issue