Initial Commit

This commit is contained in:
2026-01-15 21:52:12 +01:00
committed by erik
parent 3ed42cdeb6
commit 5a70f775f1
6702 changed files with 1389544 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import { CompareFileHandler } from '../../types';
export declare const defaultFileCompare: CompareFileHandler;
//# sourceMappingURL=defaultFileCompare.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultFileCompare.d.ts","sourceRoot":"","sources":["../../../../src/fileCompareHandler/default/defaultFileCompare.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAOhD,eAAO,MAAM,kBAAkB,EAAE,kBA+EhC,CAAA"}

View File

@@ -0,0 +1,118 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultFileCompare = void 0;
const fs_1 = __importDefault(require("fs"));
const buffer_equal_1 = __importDefault(require("buffer-equal"));
const FileDescriptorQueue_1 = require("../../fs/FileDescriptorQueue");
const fsPromise_1 = __importDefault(require("../../fs/fsPromise"));
const BufferPool_1 = require("../../fs/BufferPool");
const closeFile_1 = __importDefault(require("../../fs/closeFile"));
const MAX_CONCURRENT_FILE_COMPARE = 8;
const BUF_SIZE = 100000;
const fdQueue = new FileDescriptorQueue_1.FileDescriptorQueue(MAX_CONCURRENT_FILE_COMPARE * 2);
const bufferPool = new BufferPool_1.BufferPool(BUF_SIZE, MAX_CONCURRENT_FILE_COMPARE); // fdQueue guarantees there will be no more than MAX_CONCURRENT_FILE_COMPARE async processes accessing the buffers concurrently
exports.defaultFileCompare = {
/**
* Compares two files by content.
*/
compareSync(path1, stat1, path2, stat2, options) {
let fd1;
let fd2;
if (stat1.size !== stat2.size) {
return false;
}
const bufferPair = bufferPool.allocateBuffers();
try {
fd1 = fs_1.default.openSync(path1, 'r');
fd2 = fs_1.default.openSync(path2, 'r');
const buf1 = bufferPair.buf1;
const buf2 = bufferPair.buf2;
for (;;) {
const size1 = fs_1.default.readSync(fd1, buf1, 0, BUF_SIZE, null);
const size2 = fs_1.default.readSync(fd2, buf2, 0, BUF_SIZE, null);
if (size1 !== size2) {
return false;
}
else if (size1 === 0) {
// End of file reached
return true;
}
else if (!compareBuffers(buf1, buf2, size1)) {
return false;
}
}
}
finally {
closeFile_1.default.closeFilesSync(fd1, fd2);
bufferPool.freeBuffers(bufferPair);
}
},
/**
* Compares two files by content
*/
compareAsync(path1, stat1, path2, stat2, options) {
return __awaiter(this, void 0, void 0, function* () {
let fd1;
let fd2;
let bufferPair;
if (stat1.size !== stat2.size) {
return Promise.resolve(false);
}
return Promise.all([fdQueue.openPromise(path1, 'r'), fdQueue.openPromise(path2, 'r')])
.then(fds => {
bufferPair = bufferPool.allocateBuffers();
fd1 = fds[0];
fd2 = fds[1];
const buf1 = bufferPair.buf1;
const buf2 = bufferPair.buf2;
const compareAsyncInternal = () => Promise.all([
fsPromise_1.default.read(fd1, buf1, 0, BUF_SIZE, null),
fsPromise_1.default.read(fd2, buf2, 0, BUF_SIZE, null)
])
.then((bufferSizes) => {
const size1 = bufferSizes[0];
const size2 = bufferSizes[1];
if (size1 !== size2) {
return false;
}
else if (size1 === 0) {
// End of file reached
return true;
}
else if (!compareBuffers(buf1, buf2, size1)) {
return false;
}
else {
return compareAsyncInternal();
}
});
return compareAsyncInternal();
})
.then(
// 'finally' polyfill for node 8 and below
res => finalizeAsync(fd1, fd2, bufferPair).then(() => res), err => finalizeAsync(fd1, fd2, bufferPair).then(() => { throw err; }));
});
}
};
function compareBuffers(buf1, buf2, contentSize) {
return buffer_equal_1.default(buf1.slice(0, contentSize), buf2.slice(0, contentSize));
}
function finalizeAsync(fd1, fd2, bufferPair) {
if (bufferPair) {
bufferPool.freeBuffers(bufferPair);
}
return closeFile_1.default.closeFilesAsync(fd1, fd2, fdQueue);
}
//# sourceMappingURL=defaultFileCompare.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultFileCompare.js","sourceRoot":"","sources":["../../../../src/fileCompareHandler/default/defaultFileCompare.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,gEAAsC;AACtC,sEAAkE;AAClE,mEAA0C;AAC1C,oDAA4D;AAC5D,mEAA0C;AAI1C,MAAM,2BAA2B,GAAG,CAAC,CAAA;AACrC,MAAM,QAAQ,GAAG,MAAM,CAAA;AACvB,MAAM,OAAO,GAAG,IAAI,yCAAmB,CAAC,2BAA2B,GAAG,CAAC,CAAC,CAAA;AACxE,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA,CAAE,+HAA+H;AAE5L,QAAA,kBAAkB,GAAuB;IAClD;;OAEG;IACH,WAAW,CAAC,KAAa,EAAE,KAAe,EAAE,KAAa,EAAE,KAAe,EAAE,OAAgB;QACxF,IAAI,GAAuB,CAAA;QAC3B,IAAI,GAAuB,CAAA;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE;YAC3B,OAAO,KAAK,CAAA;SACf;QACD,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,EAAE,CAAA;QAC/C,IAAI;YACA,GAAG,GAAG,YAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAC7B,GAAG,GAAG,YAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAC7B,MAAM,IAAI,GAAG,UAAU,CAAC,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,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,CAAA,CAAC,CAAC,CAAC,CACvE,CAAA;QACT,CAAC;KAAA;CAEJ,CAAA;AAGD,SAAS,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,WAAmB;IACnE,OAAO,sBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAA;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,GAAY,EAAE,GAAY,EAAE,UAAuB;IACtE,IAAI,UAAU,EAAE;QACZ,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;KACrC;IACD,OAAO,mBAAS,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC"}

View File

@@ -0,0 +1,36 @@
import { BufferPair } from '../../fs/BufferPool';
interface RestPair {
rest1: string;
rest2: string;
}
interface RestLines {
restLines1: string[];
restLines2: string[];
}
export declare class LineBasedCompareContext {
/**
* File to compare.
*/
fd1: number;
/**
* File to compare.
*/
fd2: number;
/**
* Buffers used as temporary storage.
*/
buffer: BufferPair;
/**
* Part of a line that was split at buffer boundary in a previous read.
* Will be prefixed to the next read.
*/
rest: RestPair;
/**
* Lines that remain unprocessed from a previous read.
* Will be prefixed to the next read.
*/
restLines: RestLines;
constructor(fd1: number, fd2: number, bufferPair: BufferPair);
}
export {};
//# sourceMappingURL=LineBasedCompareContext.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineBasedCompareContext.d.ts","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/LineBasedCompareContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,UAAU,QAAQ;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,SAAS;IACf,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,qBAAa,uBAAuB;IAChC;;OAEG;IACI,GAAG,EAAE,MAAM,CAAA;IAClB;;OAEG;IACI,GAAG,EAAE,MAAM,CAAA;IAClB;;OAEG;IACI,MAAM,EAAE,UAAU,CAAA;IACzB;;;OAGG;IACI,IAAI,EAAE,QAAQ,CAAyB;IAC9C;;;OAGG;IACI,SAAS,EAAE,SAAS,CAAmC;gBAElD,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;CAK/D"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LineBasedCompareContext = void 0;
class LineBasedCompareContext {
constructor(fd1, fd2, bufferPair) {
/**
* Part of a line that was split at buffer boundary in a previous read.
* Will be prefixed to the next read.
*/
this.rest = { rest1: '', rest2: '' };
/**
* Lines that remain unprocessed from a previous read.
* Will be prefixed to the next read.
*/
this.restLines = { restLines1: [], restLines2: [] };
this.fd1 = fd1;
this.fd2 = fd2;
this.buffer = bufferPair;
}
}
exports.LineBasedCompareContext = LineBasedCompareContext;
//# sourceMappingURL=LineBasedCompareContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineBasedCompareContext.js","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/LineBasedCompareContext.ts"],"names":[],"mappings":";;;AAYA,MAAa,uBAAuB;IAwBhC,YAAY,GAAW,EAAE,GAAW,EAAE,UAAsB;QAX5D;;;WAGG;QACI,SAAI,GAAa,EAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAC,CAAA;QAC9C;;;WAGG;QACI,cAAS,GAAc,EAAC,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAC,CAAA;QAG1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,UAAU,CAAA;IAC5B,CAAC;CACJ;AA7BD,0DA6BC"}

View File

@@ -0,0 +1,15 @@
export interface CompareLinesResult {
/**
* Whether compared lines are identical.
*/
isEqual: boolean;
/**
* Lines that were not compared due to unbalanced buffers.
*/
restLines1: string[];
/**
* Lines that were not compared due to unbalanced buffers.
*/
restLines2: string[];
}
//# sourceMappingURL=CompareLinesResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CompareLinesResult.d.ts","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/CompareLinesResult.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=CompareLinesResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CompareLinesResult.js","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/CompareLinesResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
import { Options } from '../../../index';
import { LineBatch } from '../lineReader/LineBatch';
interface RestLines {
restLines1: string[];
restLines2: string[];
}
interface CompareLineBatchResult {
reachedEof: boolean;
batchIsEqual: boolean;
/**
* Lines that were not compared because the two line batches
* contained different number of lines.
* These remaining lines will be compared in the next step.
*/
restLines: RestLines;
}
/**
* Compares two batches of lines.
*
* @param lineBatch1 Batch to compare.
* @param lineBatch2 Batch to compare.
* @param context Comparison context.
* @param options Comparison options.
*/
export declare function compareLineBatches(lineBatch1: LineBatch, lineBatch2: LineBatch, options: Options): CompareLineBatchResult;
export {};
//# sourceMappingURL=compareLineBatches.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareLineBatches.d.ts","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/compareLineBatches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,UAAU,SAAS;IACf,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,UAAU,sBAAsB;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,SAAS,EAAE,SAAS,CAAA;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,sBAAsB,CAuBzH"}

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareLineBatches = void 0;
const compareLines_1 = require("./compareLines");
/**
* Compares two batches of lines.
*
* @param lineBatch1 Batch to compare.
* @param lineBatch2 Batch to compare.
* @param context Comparison context.
* @param options Comparison options.
*/
function compareLineBatches(lineBatch1, lineBatch2, options) {
const compareResult = compareLines_1.compareLines(lineBatch1.lines, lineBatch2.lines, options);
if (!compareResult.isEqual) {
return { batchIsEqual: false, reachedEof: false, restLines: emptyRestLines() };
}
const reachedEof = lineBatch1.reachedEof && lineBatch2.reachedEof;
const hasMoreLinesToProcess = compareResult.restLines1.length > 0 || compareResult.restLines2.length > 0;
if (reachedEof && hasMoreLinesToProcess) {
return { batchIsEqual: false, reachedEof: true, restLines: emptyRestLines() };
}
if (reachedEof) {
return { batchIsEqual: true, reachedEof: true, restLines: emptyRestLines() };
}
return { batchIsEqual: true, reachedEof: false,
restLines: {
restLines1: compareResult.restLines1,
restLines2: compareResult.restLines2,
}
};
}
exports.compareLineBatches = compareLineBatches;
function emptyRestLines() {
return {
restLines1: [],
restLines2: []
};
}
//# sourceMappingURL=compareLineBatches.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareLineBatches.js","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/compareLineBatches.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAkB7C;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,UAAqB,EAAE,UAAqB,EAAE,OAAgB;IAE7F,MAAM,aAAa,GAAG,2BAAY,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC/E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;QACxB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,EAAC,CAAA;KAChF;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,CAAA;IACjE,MAAM,qBAAqB,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA;IACxG,IAAI,UAAU,IAAI,qBAAqB,EAAE;QACrC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAG,SAAS,EAAE,cAAc,EAAE,EAAC,CAAA;KAChF;IAED,IAAI,UAAU,EAAE;QACZ,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAG,SAAS,EAAE,cAAc,EAAE,EAAC,CAAA;KAC/E;IAED,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK;QAC1C,SAAS,EAAE;YACP,UAAU,EAAE,aAAa,CAAC,UAAU;YACpC,UAAU,EAAE,aAAa,CAAC,UAAU;SACvC;KACJ,CAAA;AACL,CAAC;AAvBD,gDAuBC;AAED,SAAS,cAAc;IACnB,OAAO;QACH,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;KACjB,CAAA;AACL,CAAC"}

View File

@@ -0,0 +1,4 @@
import { Options } from "../../../index";
import { CompareLinesResult } from "./CompareLinesResult";
export declare function compareLines(lines1: string[], lines2: string[], options: Options): CompareLinesResult;
//# sourceMappingURL=compareLines.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareLines.d.ts","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/compareLines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAMzD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAkBrG"}

View File

@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareLines = void 0;
const TRIM_WHITE_SPACES_REGEXP = /^[ \f\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+|[ \f\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+$/g;
const TRIM_LINE_ENDING_REGEXP = /\r\n|\n$/g;
const REMOVE_WHITE_SPACES_REGEXP = /[ \f\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g;
function compareLines(lines1, lines2, options) {
if (options.ignoreEmptyLines) {
lines1 = removeEmptyLines(lines1);
lines2 = removeEmptyLines(lines2);
}
const len = Math.min(lines1.length, lines2.length);
let i = 0;
for (; i < len; i++) {
const isEqual = compareLine(options, lines1[i], lines2[i]);
if (!isEqual) {
return { isEqual: false, restLines1: [], restLines2: [] };
}
}
return {
isEqual: true,
restLines1: lines1.slice(i),
restLines2: lines2.slice(i)
};
}
exports.compareLines = compareLines;
function compareLine(options, line1, line2) {
if (options.ignoreLineEnding) {
line1 = trimLineEnding(line1);
line2 = trimLineEnding(line2);
}
if (options.ignoreWhiteSpaces) {
line1 = trimSpaces(line1);
line2 = trimSpaces(line2);
}
if (options.ignoreAllWhiteSpaces) {
line1 = removeSpaces(line1);
line2 = removeSpaces(line2);
}
return line1 === line2;
}
// Trims string like ' abc \n' into 'abc\n'
function trimSpaces(s) {
const { content, lineEnding } = separateEol(s);
const trimmed = content.replace(TRIM_WHITE_SPACES_REGEXP, '');
return trimmed + lineEnding;
}
function trimLineEnding(s) {
return s.replace(TRIM_LINE_ENDING_REGEXP, '');
}
function removeSpaces(s) {
return s.replace(REMOVE_WHITE_SPACES_REGEXP, '');
}
function removeEmptyLines(lines) {
return lines.filter(line => !isEmptyLine(line));
}
function isEmptyLine(line) {
return line === '\n' || line === '\r\n';
}
function separateEol(s) {
const len = s.length;
let lineEnding = '';
let content = s;
if (s[len - 1] === '\n') {
if (s[len - 2] === '\r') {
return {
lineEnding: '\r\n',
content: s.slice(0, len - 2)
};
}
{
lineEnding = '\n';
content = s.slice(0, len - 1);
}
}
return { content, lineEnding };
}
//# sourceMappingURL=compareLines.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareLines.js","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/compare/compareLines.ts"],"names":[],"mappings":";;;AAGA,MAAM,wBAAwB,GAAG,oJAAoJ,CAAA;AACrL,MAAM,uBAAuB,GAAG,WAAW,CAAA;AAC3C,MAAM,0BAA0B,GAAG,yEAAyE,CAAA;AAE5G,SAAgB,YAAY,CAAC,MAAgB,EAAE,MAAgB,EAAE,OAAgB;IAC7E,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC1B,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;KACpC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,M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export declare const lineBasedCompareAsync: CompareFileAsync;
//# sourceMappingURL=compareAsync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareAsync.d.ts","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/compareAsync.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQ9C,eAAO,MAAM,qBAAqB,EAAE,gBA+BnC,CAAA"}

View File

@@ -0,0 +1,75 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lineBasedCompareAsync = void 0;
const FileDescriptorQueue_1 = require("../../fs/FileDescriptorQueue");
const closeFile_1 = __importDefault(require("../../fs/closeFile"));
const fsPromise_1 = __importDefault(require("../../fs/fsPromise"));
const LineBasedCompareContext_1 = require("./LineBasedCompareContext");
const BufferPool_1 = require("../../fs/BufferPool");
const compareLineBatches_1 = require("./compare/compareLineBatches");
const readBufferedLines_1 = require("./lineReader/readBufferedLines");
const BUF_SIZE = 100000;
const MAX_CONCURRENT_FILE_COMPARE = 8;
const fdQueue = new FileDescriptorQueue_1.FileDescriptorQueue(MAX_CONCURRENT_FILE_COMPARE * 2);
const bufferPool = new BufferPool_1.BufferPool(BUF_SIZE, MAX_CONCURRENT_FILE_COMPARE); // fdQueue guarantees there will be no more than MAX_CONCURRENT_FILE_COMPARE async processes accessing the buffers concurrently
const lineBasedCompareAsync = (path1, stat1, path2, stat2, options) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const bufferSize = Math.min(BUF_SIZE, (_a = options.lineBasedHandlerBufferSize) !== null && _a !== void 0 ? _a : Number.MAX_VALUE);
let context;
try {
const fileDescriptors = yield Promise.all([fdQueue.openPromise(path1, 'r'), fdQueue.openPromise(path2, 'r')]);
context = new LineBasedCompareContext_1.LineBasedCompareContext(fileDescriptors[0], fileDescriptors[1], bufferPool.allocateBuffers());
for (;;) {
const lineBatch1 = yield readLineBatchAsync(context.fd1, context.buffer.buf1, bufferSize, context.rest.rest1, context.restLines.restLines1);
const lineBatch2 = yield readLineBatchAsync(context.fd2, context.buffer.buf2, bufferSize, context.rest.rest2, context.restLines.restLines2);
context.rest.rest1 = lineBatch1.rest;
context.rest.rest2 = lineBatch2.rest;
const compareResult = compareLineBatches_1.compareLineBatches(lineBatch1, lineBatch2, options);
if (!compareResult.batchIsEqual) {
return false;
}
if (compareResult.reachedEof) {
return compareResult.batchIsEqual;
}
context.restLines.restLines1 = compareResult.restLines.restLines1;
context.restLines.restLines2 = compareResult.restLines.restLines2;
}
}
finally {
if (context) {
bufferPool.freeBuffers(context.buffer);
yield closeFile_1.default.closeFilesAsync(context.fd1, context.fd2, fdQueue);
}
}
});
exports.lineBasedCompareAsync = lineBasedCompareAsync;
/**
* Reads a batch of lines from file starting with current position.
*
* @param fd File to read lines from.
* @param buf Buffer used as temporary line storage.
* @param bufferSize Allocated buffer size. The number of lines in the batch is limited by this size.
* @param rest Part of a line that was split at buffer boundary in a previous read.
* Will be added to result.
* @param restLines Lines that remain unprocessed from a previous read.
* Will be added to result.
*/
function readLineBatchAsync(fd, buf, bufferSize, rest, restLines) {
return __awaiter(this, void 0, void 0, function* () {
const size = yield fsPromise_1.default.read(fd, buf, 0, bufferSize, null);
return readBufferedLines_1.readBufferedLines(buf, size, bufferSize, rest, restLines);
});
}
//# sourceMappingURL=compareAsync.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareAsync.js","s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G,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IACpE,CAAC;CAAA"}

View File

@@ -0,0 +1,3 @@
import { CompareFileSync } from '../../types';
export declare const lineBasedCompareSync: CompareFileSync;
//# sourceMappingURL=compareSync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareSync.d.ts","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/compareSync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAU7C,eAAO,MAAM,oBAAoB,EAAE,eA8BlC,CAAA"}

View File

@@ -0,0 +1,60 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lineBasedCompareSync = void 0;
const fs_1 = __importDefault(require("fs"));
const closeFile_1 = __importDefault(require("../../fs/closeFile"));
const LineBasedCompareContext_1 = require("./LineBasedCompareContext");
const compareLineBatches_1 = require("./compare/compareLineBatches");
const readBufferedLines_1 = require("./lineReader/readBufferedLines");
const BUF_SIZE = 100000;
const bufferPair = {
buf1: Buffer.alloc(BUF_SIZE),
buf2: Buffer.alloc(BUF_SIZE),
busy: true
};
const lineBasedCompareSync = (path1, stat1, path2, stat2, options) => {
var _a;
const bufferSize = Math.min(BUF_SIZE, (_a = options.lineBasedHandlerBufferSize) !== null && _a !== void 0 ? _a : Number.MAX_VALUE);
let context;
try {
context = new LineBasedCompareContext_1.LineBasedCompareContext(fs_1.default.openSync(path1, 'r'), fs_1.default.openSync(path2, 'r'), bufferPair);
for (;;) {
const lineBatch1 = readLineBatchSync(context.fd1, context.buffer.buf1, bufferSize, context.rest.rest1, context.restLines.restLines1);
const lineBatch2 = readLineBatchSync(context.fd2, context.buffer.buf2, bufferSize, context.rest.rest2, context.restLines.restLines2);
context.rest.rest1 = lineBatch1.rest;
context.rest.rest2 = lineBatch2.rest;
const compareResult = compareLineBatches_1.compareLineBatches(lineBatch1, lineBatch2, options);
if (!compareResult.batchIsEqual) {
return false;
}
if (compareResult.reachedEof) {
return compareResult.batchIsEqual;
}
context.restLines.restLines1 = compareResult.restLines.restLines1;
context.restLines.restLines2 = compareResult.restLines.restLines2;
}
}
finally {
closeFile_1.default.closeFilesSync(context === null || context === void 0 ? void 0 : context.fd1, context === null || context === void 0 ? void 0 : context.fd2);
}
};
exports.lineBasedCompareSync = lineBasedCompareSync;
/**
* Reads a batch of lines from file starting with current position.
*
* @param fd File to read lines from.
* @param buf Buffer used as temporary line storage.
* @param bufferSize Allocated buffer size. The number of lines in the batch is limited by this size.
* @param rest Part of a line that was split at buffer boundary in a previous read.
* Will be added to result.
* @param restLines Lines that remain unprocessed from a previous read.
* Will be added to result.
*/
function readLineBatchSync(fd, buf, bufferSize, rest, restLines) {
const size = fs_1.default.readSync(fd, buf, 0, bufferSize, null);
return readBufferedLines_1.readBufferedLines(buf, size, bufferSize, rest, restLines);
}
//# sourceMappingURL=compareSync.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compareSync.js","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/compareSync.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAEnB,mEAA2C;AAC3C,uEAAmE;AACnE,qEAAiE;AACjE,sEAAkE;AAKlE,MAAM,QAAQ,GAAG,MAAM,CAAA;AAEvB,MAAM,UAAU,GAAe;IAC3B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC5B,IAAI,EAAE,IAAI;CACb,CAAA;AAEM,MAAM,oBAAoB,GAAoB,CAAC,KAAa,EAAE,KAAe,EAAE,KAAa,EAAE,KAAe,EAAE,OAAgB,EAAW,EAAE;;IAC/I,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAA,OAAO,CAAC,0BAA0B,mCAAI,M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G,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,CAAC,CAAA;KACxD;AACL,CAAC,CAAA;AA9BY,QAAA,oBAAoB,wBA8BhC;AAED;;;;;;;;;;GAUG;AACH,SAAS,iBAAiB,CAAC,EAAU,EAAE,GAAW,EAAE,UAAkB,EAAE,IAAY,EAAE,SAAmB;IACrG,MAAM,IAAI,GAAG,YAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,qCAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;AACpE,CAAC"}

View File

@@ -0,0 +1,7 @@
import { CompareFileHandler } from '../../types';
/**
* Compare files line by line with options to ignore
* line endings and white space differences.
*/
export declare const lineBasedFileCompare: CompareFileHandler;
//# sourceMappingURL=lineBasedFileCompare.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lineBasedFileCompare.d.ts","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/lineBasedFileCompare.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAGlC,CAAA"}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lineBasedFileCompare = void 0;
const compareSync_1 = require("./compareSync");
const compareAsync_1 = require("./compareAsync");
/**
* Compare files line by line with options to ignore
* line endings and white space differences.
*/
exports.lineBasedFileCompare = {
compareSync: compareSync_1.lineBasedCompareSync,
compareAsync: compareAsync_1.lineBasedCompareAsync
};
//# sourceMappingURL=lineBasedFileCompare.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lineBasedFileCompare.js","sourceRoot":"","sources":["../../../../src/fileCompareHandler/lines/lineBasedFileCompare.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,iDAAoD;AAGpD;;;GAGG;AACU,QAAA,oBAAoB,GAAuB;IACpD,WAAW,EAAE,kCAAoB;IACjC,YAAY,EAAE,oCAAqB;CACtC,CAAA"}

View File

@@ -0,0 +1,16 @@
export interface LineBatch {
/**
* Batch of lines available after this read operation.
*/
lines: string[];
/**
* First part of a line that was split due to buffer boundary.
* It will be used in a subsequent read to complete the next line.
*/
rest: string;
/**
* Whether we reached end of file.
*/
reachedEof: boolean;
}
//# sourceMappingURL=LineBatch.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineBatch.d.ts","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/lineReader/LineBatch.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,EAAE,OAAO,CAAA;CACtB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=LineBatch.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineBatch.js","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/lineReader/LineBatch.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,14 @@
/// <reference types="node" />
import { LineBatch } from './LineBatch';
/**
* Reads lines from given buffer.
* @param buf Buffer to read lines from.
* @param size Size of data available in buffer.
* @param allocatedBufferSize Maximum buffer storage.
* @param rest Part of a line that was split at buffer boundary in a previous read.
* Will be added to result.
* @param restLines Lines that remain unprocessed from a previous read due to unbalanced buffers.
* Will be added to result.
*/
export declare function readBufferedLines(buf: Buffer, size: number, allocatedBufferSize: number, rest: string, restLines: string[]): LineBatch;
//# sourceMappingURL=readBufferedLines.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"readBufferedLines.d.ts","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/lineReader/readBufferedLines.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAKvC;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAmBtI"}

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readBufferedLines = void 0;
const LINE_TOKENIZER_REGEXP = /[^\n]+\n?|\n/g;
/**
* Reads lines from given buffer.
* @param buf Buffer to read lines from.
* @param size Size of data available in buffer.
* @param allocatedBufferSize Maximum buffer storage.
* @param rest Part of a line that was split at buffer boundary in a previous read.
* Will be added to result.
* @param restLines Lines that remain unprocessed from a previous read due to unbalanced buffers.
* Will be added to result.
*/
function readBufferedLines(buf, size, allocatedBufferSize, rest, restLines) {
if (size === 0 && rest.length === 0) {
return { lines: [...restLines], rest: '', reachedEof: true };
}
if (size === 0) {
return { lines: [...restLines, rest], rest: '', reachedEof: true };
}
const fileContent = rest + buf.toString('utf8', 0, size);
const lines = [...restLines, ...fileContent.match(LINE_TOKENIZER_REGEXP)];
const reachedEof = size < allocatedBufferSize;
if (reachedEof) {
return {
lines, rest: '', reachedEof: true
};
}
return removeLastLine(lines);
}
exports.readBufferedLines = readBufferedLines;
/**
* Last line is usually incomplete because our buffer rarely matches exactly the end of a line.
* So we remove it from the line batch.
* The deleted line is returned as the 'rest' parameter and will be incorporate at the beginning
* of next read operation.
*/
function removeLastLine(lines) {
const lastLine = lines[lines.length - 1];
return {
lines: lines.slice(0, lines.length - 1),
rest: lastLine,
reachedEof: false
};
}
//# sourceMappingURL=readBufferedLines.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"readBufferedLines.js","sourceRoot":"","sources":["../../../../../src/fileCompareHandler/lines/lineReader/readBufferedLines.ts"],"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