fs-extender
Version:
Extras suite for node fs module
129 lines (128 loc) • 4.94 kB
TypeScript
/// <reference types="node" />
import * as fs from "../patch";
import * as internal from "./_internal";
/**
* Compare two files in a byte-to-byte comparison
*
* ```js
* import * as fs from "fs-extender"
* fs.filesByte(file1, file2,(err, areEqual)=>{
* if(areEqual){
* console.log("Are equal");
* }
* });
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - Size to use when comparing files, default is `8192`
* @param callback - the callback function that will be called after the comparison is done
* @return {Error|boolean}
*/
export declare function filesByte(path1: fs.PathLike, path2: fs.PathLike, options: internal.CompareOptionsByte | undefined, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare function filesByte(path1: fs.PathLike, path2: fs.PathLike, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
/**
* Compare two files in a hash comparison
*
* ```js
* import * as fs from "fs-extender"
* fs.filesHash(file1, file2,(err, areEqual)=>{
* if(areEqual){
* console.log("Are equal");
* }
* });
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @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`
* @param callback - the callback function that will be called after the comparison is done
* @return {Error|boolean}
*/
export declare function filesHash(path1: fs.PathLike, path2: fs.PathLike, options: internal.CompareOptionsHash | undefined, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare function filesHash(path1: fs.PathLike, path2: fs.PathLike, callback: (err: NodeJS.ErrnoException, equal: boolean) => void): void;
export declare namespace promises {
/**
* Compare two files in a hash comparison
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = await fs.promises.filesHash(file1, file2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @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 filesHash(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsHash): Promise<boolean>;
/**
* Compare two files in a byte-to-byte comparison
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = await fs.promises.filesByte(file1, file2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - Size to use when comparing files, default is `8192`
* @return {Promise<boolean>}
*/
function filesByte(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsByte): Promise<boolean>;
}
/**
* Compare two files in a byte-to-byte comparison
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = fs.filesByteSync(file1, file2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @param options - options
* - `dereference` - Dereference links, default is `false`
* - `chunkSize` - Size to use when comparing files, default is `8192`
* @return {Error|Array}
*/
export declare function filesByteSync(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsByte): boolean;
/**
* Compare two files in a hash comparison
*
* ```js
* import * as fs from "fs-extender"
* const areEqual = fs.filesHashSync(file1, file2);
* if(areEqual){
* console.log("Are equal");
* }
* ```
*
* @param path1 - the path to the first file
* @param path2 - the path to the second file
* @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 {Error|Array}
*/
export declare function filesHashSync(path1: fs.PathLike, path2: fs.PathLike, options?: internal.CompareOptionsHash): boolean;