spread-diff-patch
Version:
Diff & patch SpreadSheet files
66 lines (62 loc) • 2.98 kB
text/typescript
import { D as DiffAOA } from './DiffAOA-mlvW9HLo.mjs';
import * as xlsx from 'xlsx';
import xlsx__default, { WorkBook } from 'xlsx';
import { WorkbookFormatter } from './formatter/workbook.mjs';
/**
* Represents a workbook that stores the differences between two workbooks.
* @template T - The type of data stored in the workbook.
*/
declare class DiffWorkBook<T> {
#private;
sheets: {
[sheet: string]: DiffAOA<T>;
};
constructor();
/**
* Formats the workbook using the specified formatter.
* @param formatter - The formatter to use for formatting the workbook.
* @returns The formatted workbook.
*/
format(formatter: WorkbookFormatter<T>): xlsx.WorkBook;
/**
* Gets the number of differences in the workbook.
*/
get diffCount(): number;
/**
* Sets the number of differences in the workbook.
*/
set diffCount(value: number);
}
/**
* Reads a CSV file and parses its content into a two-dimensional array.
* @param filePath - The path to the CSV file.
* @returns A two-dimensional array representing the parsed CSV data.
* @template T - The type of data in the CSV file.
*/
declare function readCSV<T>(filePath: string): T[][];
/**
* Reads a workbook from the specified file path.
* @param filePath - The path to the workbook file.
* @returns The parsed workbook object.
*/
declare function readWorkBook(filePath: string): xlsx__default.WorkBook;
/**
* Compares two arrays of arrays (AOA) and identifies differences based on a custom comparator function.
* @param actualAOA - The actual array of arrays.
* @param expectedAOA - The expected array of arrays for comparison.
* @param comparator - A function to compare individual elements in the arrays (default is a simple !== comparison).
* @returns An instance of DiffAOA<T> representing the differences between the two arrays of arrays.
* @template T - The type of data in the arrays of arrays.
*/
declare function diff<T>(actualAOA: T[][], expectedAOA: T[][], comparator?: (actual: T, expected: T) => boolean): DiffAOA<T>;
/**
* Calculates the difference between two workbooks.
* @template T - The type of the elements in the workbooks.
* @param actualWorkBook - The actual workbook.
* @param expectedWorkBook - The expected workbook.
* @param comparator - The comparator function to compare elements in the workbooks. Defaults to a function that checks for inequality.
* @param sheetPatcher - The function to generate a patched string for sheet names. Defaults to a function that generates a string with added and removed sheet names.
* @returns - The diff workbook containing the differences between the two workbooks.
*/
declare function diffWorkBook<T>(actualWorkBook: WorkBook, expectedWorkBook: WorkBook, comparator?: (actual: T, expected: T) => boolean, sheetPatcher?: (actual: string | null, expected: string | null) => string): DiffWorkBook<T>;
export { diff, diffWorkBook, readCSV, readWorkBook };