UNPKG

fallout-utility

Version:
60 lines (59 loc) 2.25 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import { EncodingOption } from 'node:fs'; import _path from 'node:path'; export declare enum OS { WINDOWS = "win32", LINUX = "linux", MACOS = "darwin", ANDROID = "android", OPENBSD = "openbsd", FREEBSD = "freebsd", OTHER = "other" } /** * Get operation system */ export declare function getOperatingSystem(): OS; /** * Checks if debug mode is enabled * @experimental */ export declare function isDebugging(): boolean; /** * @deprecated This is a dumb idea (Already implemented in path module) */ export declare const path: _path.PlatformPath; export interface CreateNewFileOptions<T> { formatReadData?: (data: string | Buffer, defaultContent: T) => T; encodeFileData?: (data: T) => any; encoding?: EncodingOption; } export interface CreateNewFileAsyncOptions<T> { formatReadData?: (data: string | Buffer, defaultContent: T) => Promise<T> | T; encodeFileData?: (data: T) => any | Promise<any>; encoding?: EncodingOption; } /** * Creates file if doesn't exists and reads the file * @param filePath File path * @param defaultContent Default file content * @param options File create options */ export declare function createReadFile<T>(filePath: string, defaultContent: T, options?: CreateNewFileOptions<T> & Required<Pick<CreateNewFileOptions<T>, 'formatReadData'>>): T; export declare function createReadFile<T>(filePath: string, defaultContent: T, options?: CreateNewFileOptions<T>): string | Buffer; /** * Creates file if doesn't exists and reads the file * @param filePath File path * @param defaultContent Default file content * @param options File create options */ export declare function createReadFileAsync<T>(filePath: string, defaultContent: T, options?: CreateNewFileAsyncOptions<T> & Required<Pick<CreateNewFileAsyncOptions<T>, 'formatReadData'>>): Promise<T>; export declare function createReadFileAsync<T>(filePath: string, defaultContent: T, options?: CreateNewFileAsyncOptions<T>): Promise<string | Buffer>; /** * Checks if a string is a valid IPv4 * @param ip String to check * @deprecated This is crazy */ export declare function isValidIPv4(ip: string): boolean;