@push.rocks/smartfile
Version:
Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.
152 lines (151 loc) • 5.32 kB
TypeScript
import * as plugins from './smartfile.plugins.js';
import { Smartfile } from './smartfile.classes.smartfile.js';
/**
*
* @param filePath
* @returns {boolean}
*/
export declare const fileExistsSync: (filePath: any) => boolean;
/**
*
* @param filePath
* @returns {any}
*/
export declare const fileExists: (filePath: any) => Promise<boolean>;
/**
* Checks if given path points to an existing directory
*/
export declare const isDirectory: (pathArg: string) => boolean;
/**
* Checks if given path points to an existing directory
*/
export declare const isDirectorySync: (pathArg: string) => boolean;
/**
* Checks if a given path points to an existing file
*/
export declare const isFile: (pathArg: any) => boolean;
/**
* copies a file from A to B on the local disk
*/
export declare const copy: (fromArg: string, toArg: string) => Promise<boolean>;
/**
* copies a file SYNCHRONOUSLY from A to B on the local disk
*/
export declare const copySync: (fromArg: string, toArg: string) => boolean;
/**
* ensures that a directory is in place
*/
export declare const ensureDir: (dirPathArg: string) => Promise<void>;
/**
* ensures that a directory is in place
*/
export declare const ensureDirSync: (dirPathArg: string) => void;
/**
* ensure an empty directory
* @executes ASYNC
*/
export declare const ensureEmptyDir: (dirPathArg: string) => Promise<void>;
/**
* ensure an empty directory
* @executes SYNC
*/
export declare const ensureEmptyDirSync: (dirPathArg: string) => void;
/**
* ensures that a file is on disk
* @param filePath the filePath to ensureDir
* @param the fileContent to place into a new file in case it doesn't exist yet
* @returns Promise<void>
* @exec ASYNC
*/
export declare const ensureFile: (filePathArg: any, initFileStringArg: any) => Promise<void>;
/**
* ensures that a file is on disk
* @param filePath the filePath to ensureDir
* @param the fileContent to place into a new file in case it doesn't exist yet
* @returns Promise<void>
* @exec SYNC
*/
export declare const ensureFileSync: (filePathArg: string, initFileStringArg: string) => void;
/**
* removes a file or folder from local disk
*/
export declare const remove: (pathArg: string) => Promise<void>;
/**
* removes a file SYNCHRONOUSLY from local disk
*/
export declare const removeSync: (pathArg: string) => void;
/**
* removes an array of filePaths from disk
*/
export declare const removeMany: (filePathArrayArg: string[]) => Promise<void>;
/**
* like removeFilePathArray but SYNCHRONOUSLY
*/
export declare const removeManySync: (filePathArrayArg: string[]) => void;
/**
*
* @param filePathArg
* @param fileTypeArg
* @returns {any}
*/
export declare const toObjectSync: (filePathArg: any, fileTypeArg?: any) => any;
/**
* reads a file content to a String
*/
export declare const toStringSync: (filePath: string) => string;
export declare const toBuffer: (filePath: string) => Promise<Buffer>;
export declare const toBufferSync: (filePath: string) => Buffer;
/**
* Creates a Readable Stream from a file path.
* @param filePath The path to the file.
* @returns {fs.ReadStream}
*/
export declare const toReadStream: (filePath: string) => plugins.fs.ReadStream;
export declare const fileTreeToHash: (dirPathArg: string, miniMatchFilter: string) => Promise<string>;
/**
* creates a smartfile array from a directory
* @param dirPathArg the directory to start from
* @param miniMatchFilter a minimatch filter of what files to include
*/
export declare const fileTreeToObject: (dirPathArg: string, miniMatchFilter: string) => Promise<Smartfile[]>;
/**
* lists Folders in a directory on local disk
* @returns Promise with an array that contains the folder names
*/
export declare const listFolders: (pathArg: string, regexFilter?: RegExp) => Promise<string[]>;
/**
* lists Folders SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export declare const listFoldersSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists Files in a directory on local disk
* @returns Promise
*/
export declare const listFiles: (pathArg: string, regexFilter?: RegExp) => Promise<string[]>;
/**
* lists Files SYNCHRONOUSLY in a directory on local disk
* @returns an array with the folder names as strings
*/
export declare const listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists all items (folders AND files) in a directory on local disk
* @returns Promise<string[]>
*/
export declare const listAllItems: (pathArg: string, regexFilter?: RegExp) => Promise<string[]>;
/**
* lists all items (folders AND files) in a directory on local disk
* @returns an array with the folder names as strings
* @executes SYNC
*/
export declare const listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
/**
* lists a file tree using a miniMatch filter
* note: if the miniMatch Filter is an absolute path, the cwdArg will be omitted
* @returns Promise<string[]> string array with the absolute paths of all matching files
*/
export declare const listFileTree: (dirPathArg: string, miniMatchFilter: string, absolutePathsBool?: boolean) => Promise<string[]>;
/**
* checks wether a file is ready for processing
*/
export declare const waitForFileToBeReady: (filePathArg: string) => Promise<void>;