fs-extender
Version:
Extras suite for node fs module
138 lines (137 loc) • 5.61 kB
TypeScript
/// <reference types="node" />
import * as fs from "../patch";
import * as internal from "./_internal";
/**
* Compare two directories in a byte-to-byte file comparison
* Note: This method will compare all sub-folder's
*
* ```js
* import * as fs from "fs-extender"
* fs.dirByte(dir1, dir2,(err, areEqual)=>{
* if(areEqual){
* console.log("Are equal");
* }
* });
* ```
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - the size in bytes used to verify equality default to `8192`
* @param callback - the callback function that will be called after the comparison is done
* @return {Error|boolean}
*/
export declare function dirByte(path1: fs.PathLike, path2: fs.PathLike, options: internal.CompareOptionsByte | undefined, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare function dirByte(path1: fs.PathLike, path2: fs.PathLike, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
/**
* Compare two directories with a hash file comparison
* Note: This method will compare all sub-folder's
*
* ```js
* import * as fs from "fs-extender"
* fs.dirHash(dir1, dir2,(err, areEqual)=>{
* if(areEqual){
* console.log("Are equal");
* }
* });
* ```
*
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `hash` - the type of hash to use in comparison, default to `sha512`
* - `encoding` - the type of hash encoding used to compare the files, default to `hex`
* - `ignoreError` - If true will ignore error's when trying to compare a path that is not a directory, default: false
* @param callback - the callback function that will be called after the comparison is done
* @return {Error|boolean}
*/
export declare function dirHash(path1: fs.PathLike, path2: fs.PathLike, options: internal.CompareOptionsHash | undefined, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare function dirHash(path1: fs.PathLike, path2: fs.PathLike, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare namespace promises {
/**
* Compare two directories with a hash file comparison
* Note: This method will compare all sub-folder's
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = await fs.promises.dirHash(dir1, dir2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `hash` - the type of hash to use in comparison, default to `sha512`
* - `encoding` - the type of hash encoding used to compare the files, default to `hex`
* @return {Promise<boolean>}
*/
function dirHash(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsHash): Promise<boolean>;
/**
* Compare two directories in a byte-to-byte file comparison
* Note: This method will compare all sub-folder's
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = await fs.promises.dirByte(dir1, dir2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - the size in bytes used to verify equality default to `8192`
* @return {Promise<boolean>}
*/
function dirByte(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsByte): Promise<boolean>;
}
/**
* Compare two directories in a byte-to-byte file comparison
* Note: This method will compare all sub-folder's
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = fs.dirByteSync(dir1, dir2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - the size in bytes used to verify equality default to `8192`
* @return {boolean}
*/
export declare function dirByteSync(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsByte): boolean;
/**
* Compare two directories with a hash file comparison
* Note: This method will compare all sub-folder's
*
* * ```js
* import * as fs from "fs-extender"
* const areEqual = fs.dirHashSync(dir1, dir2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first directory
* @param path2 - the path to the second directory
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `hash` - the type of hash to use in comparison, default to `sha512`
* - `encoding` - the type of hash encoding used to compare the files, default to `hex`
* - `ignoreError` - If true will ignore error's when trying to compare a path that is not a directory, default: false
* @return {boolean}
*/
export declare function dirHashSync(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsHash): boolean;