@stryke/fs
Version:
A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.
78 lines (77 loc) • 2.74 kB
TypeScript
export type XOptions = null | {
readonly keys?: null | RegExp;
readonly order?: boolean;
readonly exact?: boolean;
readonly multi?: boolean;
readonly longer?: boolean;
readonly string?: boolean;
readonly comment?: boolean;
readonly literal?: boolean;
readonly null?: boolean;
readonly tag?: null | (<Table extends object & {
[key: string | symbol]: any;
}, Key extends string | symbol, Array extends any[], Index extends number, Tag extends string>(this: void, each: {
table: Table;
key: Key;
tag: Tag;
} | {
array: Array;
index: Index;
tag: Tag;
} | {
table: Table;
key: Key;
array: Array;
index: Index;
tag: Tag;
}) => void);
};
export interface TomlReadOptions {
specificationVersion?: 1.0 | 0.5 | 0.4 | 0.3 | 0.2 | 0.1;
multilineStringJoiner?: string;
useBigInt?: boolean | number;
xOptions?: XOptions;
}
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param options - TOML parse options
* @returns Object the TOML content of the file represents
*/
export declare function readTomlFileSync<T extends object = any>(path: string, options?: TomlReadOptions): T;
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param options - TOML parse options
* @returns Object the TOML content of the file represents
*/
export declare function readTomlFile<T extends object = any>(path: string, options?: TomlReadOptions): Promise<T>;
export interface TomlWriteOptions {
integer?: number;
newline?: "\n" | "\r\n";
newlineAround?: "document" | "section" | "header" | "pairs" | "pair";
indent?: string | number;
T?: "T" | "t" | " ";
Z?: "Z" | "z";
xNull?: boolean;
xBeforeNewlineInMultilineTable?: "," | "";
forceInlineArraySpacing?: 0 | 1 | 2 | 3;
}
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param data - data which should be serialized/formatted to TOML and written to the file
* @param options - TOML parse options
*/
export declare function writeTomlFileSync<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): void;
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param data - data which should be serialized/formatted to TOML and written to the file
* @param options - TOML parse options
*/
export declare function writeTomlFile<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): Promise<void>;