mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 09:51:01 -05:00
Made a few utility types for writeFile
options
This commit is contained in:
parent
88b6d0607a
commit
79519efc22
1 changed files with 32 additions and 0 deletions
32
src/utils/io/write-file-options.ts
Normal file
32
src/utils/io/write-file-options.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { writeFileSync } from "node:fs";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
|
||||
/**
|
||||
* Options that can be used with `fs.writeFile()` to write a file asynchronously.
|
||||
*/
|
||||
export type AsyncWriteFileOptions = Parameters<typeof writeFile>[2];
|
||||
|
||||
/**
|
||||
* Options that can be used with `fs.writeFileSync()` to write a file synchronously.
|
||||
*/
|
||||
export type SyncWriteFileOptions = Parameters<typeof writeFileSync>[2];
|
||||
|
||||
/**
|
||||
* All possible options that can be passed to `fs.writeFile()` and `fs.writeFileSync()`.
|
||||
*/
|
||||
export type WriteFileOptions = AsyncWriteFileOptions | SyncWriteFileOptions;
|
||||
|
||||
/**
|
||||
* Object-style options that can be used with `fs.writeFile()` to write a file asynchronously.
|
||||
*/
|
||||
export type AsyncWriteFileOptionsObject = Exclude<AsyncWriteFileOptions, string>;
|
||||
|
||||
/**
|
||||
* Object-style options that can be used with `fs.writeFileSync()` to write a file synchronously.
|
||||
*/
|
||||
export type SyncWriteFileOptionsObject = Exclude<SyncWriteFileOptions, string>;
|
||||
|
||||
/**
|
||||
* All possible object-style options that can be passed to `fs.writeFile()` and `fs.writeFileSync()`.
|
||||
*/
|
||||
export type WriteFileOptionsObject = AsyncWriteFileOptionsObject | SyncWriteFileOptionsObject;
|
Loading…
Reference in a new issue