main funcions fixes

This commit is contained in:
2025-09-29 22:06:11 +09:00
parent 40e016e128
commit c8c3274527
7995 changed files with 1517998 additions and 1057 deletions

22
desktop-operator/node_modules/dir-compare/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright 2014 Liviu Grigorescu (grigoresculiviu@gmail.com)
This project is free software released under the MIT license:
http://www.opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

365
desktop-operator/node_modules/dir-compare/README.md generated vendored Normal file
View File

@@ -0,0 +1,365 @@
dir-compare
==========
Node JS directory compare
**Starting with v3.0.0 the CLI utility moved to [dir-compare-cli](https://www.npmjs.com/package/dir-compare-cli).**
[![Build status](https://ci.appveyor.com/api/projects/status/fpnqkr2gfg7pwkxk/branch/master?svg=true)](https://ci.appveyor.com/project/gliviu/dir-compare)
[![codecov.io](http://codecov.io/github/gliviu/dir-compare/coverage.svg?branch=master)](http://codecov.io/github/gliviu/dir-compare?branch=master)
- [Installation](#installation)
- [Library](#library)
* [Use](#use)
* [Api](#api)
* [Glob patterns](#glob-patterns)
* [Symbolic links](#symbolic-links)
* [Handling permission denied errors](#handling-permission-denied-errors)
- [Extension points](#extension-points)
* [File content comparators](#file-content-comparators)
+ [Ignore line endings and white spaces](#ignore-line-endings-and-white-spaces)
* [Glob filter](#glob-filter)
+ [Implement .gitignore filter](#implement-gitignore-filter)
* [Name comparators](#name-comparators)
* [Result builder](#result-builder)
- [UI tools](#ui-tools)
- [Changelog](#changelog)
# Installation
```bash
npm install dir-compare
```
# Library
## Use
```javascript
const dircompare = require('dir-compare');
const options = { compareSize: true };
// Multiple compare strategy can be used simultaneously - compareSize, compareContent, compareDate, compareSymlink.
// If one comparison fails for a pair of files, they are considered distinct.
const path1 = '...';
const path2 = '...';
// Synchronous
const res = dircompare.compareSync(path1, path2, options)
print(res)
// Asynchronous
dircompare.compare(path1, path2, options)
.then(res => print(res))
.catch(error => console.error(error));
function print(result) {
console.log('Directories are %s', result.same ? 'identical' : 'different')
console.log('Statistics - equal entries: %s, distinct entries: %s, left only entries: %s, right only entries: %s, differences: %s',
result.equal, result.distinct, result.left, result.right, result.differences)
result.diffSet.forEach(dif => console.log('Difference - path: %s, name1: %s, type1: %s, name2: %s, type2: %s, state: %s',
dif.relativePath, dif.name1, dif.type1, dif.name2, dif.type2, dif.state))
}
```
Typescript
```typescript
import { compare, compareSync, Options, Result } from "dir-compare";
const path1 = '...';
const path2 = '...';
const options: Options = { compareSize: true };
const res: Result = compareSync(path1, path2, options);
console.log(res)
compare(path1, path2, options)
.then(res => console.log(res))
.catch(error => console.error(error));
```
## Api
```typescript
compare(path1: string, path2: string, options?: Options): Promise<Result>
compareSync(path1: string, path2: string, options?: Options): Result
```
More details can be found in the reference documentation:
* [compare](https://gliviu.github.io/dc-api/functions/compare.html)
* [compareSync](https://gliviu.github.io/dc-api/functions/compareSync.html)
* [Options](https://gliviu.github.io/dc-api/interfaces/Options.html)
* [Result](https://gliviu.github.io/dc-api/interfaces/Result.html)
Common options:
* [compareSize](https://gliviu.github.io/dc-api/interfaces/Options.html#compareSize)
* [compareContent](https://gliviu.github.io/dc-api/interfaces/Options.html#compareContent)
* [compareDate](https://gliviu.github.io/dc-api/interfaces/Options.html#compareDate)
* [excludeFilter](https://gliviu.github.io/dc-api/interfaces/Options.html#excludeFilter)
* [includeFilter](https://gliviu.github.io/dc-api/interfaces/Options.html#includeFilter)
* [ignoreCase](https://gliviu.github.io/dc-api/interfaces/Options.html#ignoreCase)
* [skipSubdirs](https://gliviu.github.io/dc-api/interfaces/Options.html#skipSubdirs)
* [skipEmptyDirs](https://gliviu.github.io/dc-api/interfaces/Options.html#skipEmptyDirs)
## Glob patterns
[Minimatch](https://www.npmjs.com/package/minimatch) patterns are used to include/exclude files to be compared.
The pattern is matched against the relative path of the entry being compared.
Following examples assume we are comparing two [dir-compare](https://github.com/gliviu/dir-compare) code bases.
```javascript
const options = {
excludeFilter: ".git,node_modules", // exclude git and node modules directories
excludeFilter: "expected" , // exclude '/tests/expected' directory
excludeFilter: "/tests/expected" , // exclude '/tests/expected' directory
excludeFilter: "**/expected" , // exclude '/tests/expected' directory
excludeFilter: "**/tests/**/*.js" , // exclude all js files in '/tests' directory and subdirectories
includeFilter: "*.js,*.yml" , // include js and yaml files
includeFilter: "/tests/**/*.js" , // include all js files in '/tests' directory and subdirectories
includeFilter: "**/tests/**/*.ts" // include all js files in '/tests' directory and subdirectories
}
```
This behavior can be changed with [Glob filter extensions](#glob-filter).
## Symbolic links
Unless `compareSymlink` option is used, symbolic links are resolved and any comparison is applied to the file/directory they point to.
Circular loops are handled by breaking the loop as soon as it is detected.
Version `1.x` treats broken links as `ENOENT: no such file or directory`.
Since `2.0` they are treated as a special type of entry - `broken-link` - and are available as stats (`totalBrokenLinks`, `distinctBrokenLinks`, ...).
Using `compareSymlink` option causes `dircompare` to check symlink values for equality.
In this mode two entries with identical names are considered different if
* one is symlink, the other is not
* both are symlinks but point to different locations
These rules are applied in addition to the other comparison modes; ie. by content, by size...
If entries are different because of symlinks, `reason` will be `different-symlink`. Also statistics summarize differences caused by symbolic links.
## Handling permission denied errors
Unreadable files or directories are normally reported as errors. The comparison will be interrupted with an `EACCES` exception.
This behavior can be altered with [Options.handlePermissionDenied](https://gliviu.github.io/dc-api/interfaces/Options.html#handlePermissionDenied).
# Extension points
## File content comparators
By default file content is binary compared. As of version 1.5.0 custom file comparison handlers may be specified.
Custom handlers are specified by `compareFileSync` and `compareFileAsync` options which correspond to `dircompare.compareSync()` or `dircompare.compare()` methods.
A couple of handlers are included in the library:
* binary sync compare - `dircompare.fileCompareHandlers.defaultFileCompare.compareSync`
* binary async compare - `dircompare.fileCompareHandlers.defaultFileCompare.compareAsync`
* text sync compare - `dircompare.fileCompareHandlers.lineBasedFileCompare.compareSync`
* text async compare - `dircompare.fileCompareHandlers.lineBasedFileCompare.compareAsync`
Use [defaultFileCompare](https://github.com/gliviu/dir-compare/blob/master/src/FileCompareHandler/default/defaultFileCompare.ts) as an example to create your own.
### Ignore line endings and white spaces
Line based comparator can be used to ignore line ending and white space differences.
```javascript
const dircompare = require('dir-compare');
const options = {
compareContent: true,
compareFileSync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareSync,
compareFileAsync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareAsync,
ignoreLineEnding: true, // Ignore crlf/lf line ending differences
ignoreWhiteSpaces: true, // Ignore white spaces at the beginning and end of a line (similar to 'diff -b')
ignoreAllWhiteSpaces: true, // Ignore all white space differences (similar to 'diff -w')
ignoreEmptyLines: true // Ignores differences caused by empty lines (similar to 'diff -B')
};
const path1 = '...';
const path2 = '...';
const res = dircompare.compareSync(path1, path2, options);
console.log(res)
dircompare.compare(path1, path2, options)
.then(res => console.log(res))
```
## Glob filter
The current implementation of the glob filter uses minimatch and is based on [includeFilter and excludeFilter options](#glob-patterns). While it is meant to fit most use cases, [some scenarios](https://github.com/gliviu/dir-compare/issues/67) are not addressed.
Use [filterHandler option](https://gliviu.github.io/dc-api/interfaces/Options.html#filterHandler) to alter this behavior.
The following example demonstrates how to include only files with a specific extension in our comparison.
```typescript
import { Options, compareSync, Result, FilterHandler, Entry, filterHandlers } from 'dir-compare'
import { extname } from 'path'
var d1 = '...';
var d2 = '...';
const filterByfileExtension: FilterHandler = (entry: Entry, relativePath: string, options: Options): boolean => {
if (!options.fileExtension) {
// Fallback on the default 'minimatch' implementation
return filterHandlers.defaultFilterHandler(entry, relativePath, options)
}
return options.fileExtension === extname(entry.name)
}
const options: Options = {
compareSize: true,
fileExtension: '.txt',
filterHandler: filterByfileExtension
}
const res: Result = compareSync(d1, d2, options)
```
For reference, the default minimatch filter can be found in [defaultFilterHandler](https://github.com/gliviu/dir-compare/blob/master/src/FilterHandler/defaultFilterHandler.ts) which is exposed by [filterHandlers property](https://gliviu.github.io/dc-api/variables/filterHandlers.html).
### Implement .gitignore filter
[Globby](https://www.npmjs.com/package/globby) library provides the functionality to parse and apply `.gitignore` rules.
This is a [sample implementation](https://github.com/gliviu/dir-compare/blob/master/test/extended/gitignoreSupport/gitignoreFilter.ts) that uses globby and dir-compare filter extension.
Usage:
```typescript
import { Options, compareSync, Result} from 'dir-compare'
import { getGitignoreFilter } from './gitignoreFilter.js'
var d1 = '...';
var d2 = '...';
const options: Options = {
compareSize: true,
filterHandler: getGitignoreFilter(d1, d2),
includeFilter: '*.js' // if present, regular filters are applied after .gitignore rules.
}
const res: Result = compareSync(d1, d2, options)
```
## Name comparators
If [default](https://github.com/gliviu/dir-compare/blob/master/src/NameCompare/defaultNameCompare.ts) name comparison is not enough, custom behavior can be specified with [compareNameHandler](https://gliviu.github.io/dc-api/interfaces/Options.html#compareNameHandler) option.
Following example adds the possibility to ignore file extensions.
```typescript
import { Options, compare } from 'dir-compare'
import path from 'path'
const options: Options = {
compareSize: false, // compare only name by disabling size and content criteria
compareContent: false,
compareNameHandler: customNameCompare, // new name comparator used to ignore extensions
ignoreExtension: true, // supported by the custom name compare below
};
function customNameCompare(name1: string, name2: string, options: Options) {
if (options.ignoreCase) {
name1 = name1.toLowerCase()
name2 = name2.toLowerCase()
}
if (options.ignoreExtension) {
name1 = path.basename(name1, path.extname(name1))
name2 = path.basename(name2, path.extname(name2))
}
return ((name1 === name2) ? 0 : ((name1 > name2) ? 1 : -1))
}
const path1 = '/tmp/a';
const path2 = '/tmp/b';
const res = compare(path1, path2, options).then(res => {
console.log(`Same: ${res.same}`)
if (!res.diffSet) {
return
}
res.diffSet.forEach(dif => console.log(`${dif.name1} ${dif.name2} ${dif.state}`))
})
// Outputs
// icon.svg icon.png equal
// logo.svg logo.jpg equal
```
For reference, the default name comparator can be found in [defaultNameCompare](https://github.com/gliviu/dir-compare/blob/master/src/NameCompare/defaultNameCompare.ts) which is exposed by [compareNameHandlers property](https://gliviu.github.io/dc-api/variables/compareNameHandlers.html).
## Result builder
[Result builder](https://gliviu.github.io/dc-api/interfaces/Options.html#resultBuilder) is called for each pair of entries encountered during comparison. Its purpose is to append entries in `diffSet` and eventually update `statistics` object with new stats.
If needed it can be replaced with custom implementation.
```javascript
const dircompare = require("dircompare")
const customResultBuilder = function (entry1, entry2, state, level, relativePath, options, statistics, diffSet, reason) {
...
}
const options = {
compareSize: true,
resultBuilder: customResultBuilder
}
const res = dircompare.compareSync('...', '...', options)
```
The [default](https://github.com/gliviu/dir-compare/blob/master/src/ResultBuilder/defaultResultBuilderCallback.ts) builder can be used as an example.
# UI tools
* [dir-compare-cli](https://github.com/gliviu/dir-compare-cli)
* [Visual Studio Code - Compare Folders](https://marketplace.visualstudio.com/items?itemName=moshfeu.compare-folders)
# Changelog
* v4.2.0
* Updated dependencies
* Increased test coverage
* v4.1.0
* Possibility to alter the default [Glob filter](#glob-filter) behavior
* [Ignore files and directories according to .gitignore rules](#implement-gitignore-filter).
* New [origin](https://gliviu.github.io/dc-api/interfaces/Entry.html#origin) field in Entry to distinguish between the left or right directory
* Improved api documentation
* v4.0.0
* Switched project to typescript
* [Async comparator](https://gliviu.github.io/dc-api/functions/compare.html) improvements when comparing large directory structures
* Heap usage has decreased 3x compared to previous version
* Works 2x faster when comparing by content
* Better concurrency. UI apps will be more responsive while comparison is ongoing
Breaking changes:
* Using this library to compare two files will ignore the name of the files. More details in [#48](https://github.com/gliviu/dir-compare/issues/48)
* Removed support for node 8, 9
* v3.3.0 Added `skipEmptyDirs` option
* v3.2.0 [Handle permission denied errors](#handling-permission-denied-errors)
* v3.1.0 Added `ignoreAllWhiteSpaces` and `ignoreEmptyLines` options
* v3.0.0 Moved CLI component into separate project [dir-compare-cli](https://github.com/gliviu/dir-compare-cli)
* v2.4.0 [New option](https://gliviu.github.io/dc-api/interfaces/Options.html#compareNameHandler) to customize file/folder name comparison
* v2.3.0 Fixes
* v2.1.0 Removed [bluebird](https://github.com/petkaantonov/bluebird/#%EF%B8%8Fnote%EF%B8%8F) dependency
* v2.0.0
* New option to compare symlinks.
* New field indicating reason for two entries being distinct.
* Improved command line output format.
* Tests are no longer part of published package.
* Generated [Api](https://gliviu.github.io/dc-api) documentation.
Breaking changes:
* Broken links are no longer treated as errors. As a result there are new statistics (leftBrokenLinks, rightBrokenLinks, distinctBrokenLinks, totalBrokenLinks) and new entry type - broken-link.
Details in [Symbolic links](#symbolic-links).
* Typescript correction: new interface `Result` replaced `Statistics`.
* v1.8.0
* globstar patterns
* typescript corrections
* removed support for node 0.11, 0.12, iojs
* v1.7.0 performance improvements
* v1.6.0 typescript support
* v1.5.0 added option to ignore line endings and white space differences
* v1.3.0 added date tolerance option
* v1.2.0 added compare by date option
* v1.1.0
* detect symlink loops
* improved color scheme for command line utility
* v1.0.0
* asynchronous comparison
* new library options: noDiffSet, resultBuilder
* new statistics: distinctFiles, equalFiles, leftFiles, rightFiles, distinctDirs, equalDirs, leftDirs, rightDirs
* new --async command line option
* Fix for https://github.com/tj/commander.js/issues/125
* v0.0.3 Fix file ordering issue for newer node versions

View File

@@ -0,0 +1,10 @@
import { Entry, EntryOrigin } from '..';
import { ExtOptions } from '../ExtOptions';
export declare const EntryBuilder: {
/**
* Returns the sorted list of entries in a directory.
*/
buildDirEntries(rootEntry: Entry, dirEntries: string[], relativePath: string, origin: EntryOrigin, options: ExtOptions): Entry[];
buildEntry(absolutePath: string, path: string, name: string, origin: EntryOrigin, options: ExtOptions): Entry;
};
//# sourceMappingURL=EntryBuilder.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryBuilder.d.ts","sourceRoot":"","sources":["../../../src/Entry/EntryBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK1C,eAAO,MAAM,YAAY;IACxB;;OAEG;+BACwB,KAAK,cAAc,MAAM,EAAE,gBAAgB,MAAM,UAAU,WAAW,WAAW,UAAU,GAAG,KAAK,EAAE;6BAmBvG,MAAM,QAAQ,MAAM,QAAQ,MAAM,UAAU,WAAW,WAAW,UAAU,GAAG,KAAK;CAwB7G,CAAA"}

View File

@@ -0,0 +1,100 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryBuilder = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const EntryComparator_1 = require("./EntryComparator");
const PATH_SEP = path_1.default.sep;
exports.EntryBuilder = {
/**
* Returns the sorted list of entries in a directory.
*/
buildDirEntries(rootEntry, dirEntries, relativePath, origin, options) {
const res = [];
for (let i = 0; i < dirEntries.length; i++) {
const entryName = dirEntries[i];
const entryAbsolutePath = rootEntry.absolutePath + PATH_SEP + entryName;
const entryPath = rootEntry.path + PATH_SEP + entryName;
const entry = this.buildEntry(entryAbsolutePath, entryPath, entryName, origin, options);
if (options.skipSymlinks && entry.isSymlink) {
entry.stat = undefined;
}
if (filterEntry(entry, relativePath, options)) {
res.push(entry);
}
}
return res.sort((a, b) => EntryComparator_1.EntryComparator.compareEntry(a, b, options));
},
buildEntry(absolutePath, path, name, origin, options) {
const stats = getStatIgnoreBrokenLink(absolutePath);
const isDirectory = stats.stat.isDirectory();
let isPermissionDenied = false;
if (options.handlePermissionDenied) {
const isFile = !isDirectory;
isPermissionDenied = hasPermissionDenied(absolutePath, isFile, options);
}
return {
name,
absolutePath,
path,
origin,
stat: stats.stat,
lstat: stats.lstat,
isSymlink: stats.lstat.isSymbolicLink(),
isBrokenLink: stats.isBrokenLink,
isDirectory,
isPermissionDenied
};
},
};
function hasPermissionDenied(absolutePath, isFile, options) {
if (isFile && !options.compareContent) {
return false;
}
try {
fs_1.default.accessSync(absolutePath, fs_1.default.constants.R_OK);
return false;
}
catch (_a) {
return true;
}
}
function getStatIgnoreBrokenLink(absolutePath) {
const lstat = fs_1.default.lstatSync(absolutePath);
try {
return {
stat: fs_1.default.statSync(absolutePath),
lstat: lstat,
isBrokenLink: false
};
}
catch (error) {
if (error.code === 'ENOENT') {
return {
stat: lstat,
lstat: lstat,
isBrokenLink: true
};
}
throw error;
}
}
/**
* Filter entries by name. Returns true if the entry is to be processed.
*/
function filterEntry(entry, relativePath, options) {
if (entry.isSymlink && options.skipSymlinks) {
return false;
}
if (options.skipEmptyDirs && entry.stat.isDirectory() && isEmptyDir(entry.absolutePath)) {
return false;
}
return options.filterHandler(entry, relativePath, options);
}
function isEmptyDir(path) {
return fs_1.default.readdirSync(path).length === 0;
}
//# sourceMappingURL=EntryBuilder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryBuilder.js","sourceRoot":"","sources":["../../../src/Entry/EntryBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA8B;AAC9B,gDAA4B;AAG5B,uDAAmD;AAEnD,MAAM,QAAQ,GAAG,cAAS,CAAC,GAAG,CAAA;AAEjB,QAAA,YAAY,GAAG;IAC3B;;OAEG;IACH,eAAe,CAAC,SAAgB,EAAE,UAAoB,EAAE,YAAoB,EAAE,MAAmB,EAAE,OAAmB;QACrH,MAAM,GAAG,GAAY,EAAE,CAAA;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,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AAC,KAAK,CAAC,YAAY,CAAC,EAAE;QACxF,OAAO,KAAK,CAAA;KACZ;IAED,OAAO,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;AAC3D,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,YAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AACzC,CAAC"}

View File

@@ -0,0 +1,9 @@
import { Entry } from "..";
import { ExtOptions } from "../ExtOptions";
/**
* Determines order criteria for sorting entries in a directory.
*/
export declare const EntryComparator: {
compareEntry(a: Entry, b: Entry, options: ExtOptions): number;
};
//# sourceMappingURL=EntryComparator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryComparator.d.ts","sourceRoot":"","sources":["../../../src/Entry/EntryComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAC,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,eAAe;oBACV,KAAK,KAAK,KAAK,WAAW,UAAU,GAAG,MAAM;CAe9D,CAAA"}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryComparator = void 0;
/**
* Determines order criteria for sorting entries in a directory.
*/
exports.EntryComparator = {
compareEntry(a, b, options) {
if (a.isBrokenLink && b.isBrokenLink) {
return options.compareNameHandler(a.name, b.name, options);
}
else if (a.isBrokenLink) {
return -1;
}
else if (b.isBrokenLink) {
return 1;
}
else if (a.stat.isDirectory() && b.stat.isFile()) {
return -1;
}
else if (a.stat.isFile() && b.stat.isDirectory()) {
return 1;
}
else {
return options.compareNameHandler(a.name, b.name, options);
}
}
};
//# sourceMappingURL=EntryComparator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryComparator.js","sourceRoot":"","sources":["../../../src/Entry/EntryComparator.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACU,QAAA,eAAe,GAAG;IAC9B,YAAY,CAAE,CAAQ,EAAE,CAAQ,EAAE,OAAmB;QACpD,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,YAAY,EAAE;YACrC,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SAC1D;aAAM,IAAI,CAAC,CAAC,YAAY,EAAE;YAC1B,OAAO,CAAC,CAAC,CAAA;SACT;aAAM,IAAI,CAAC,CAAC,YAAY,EAAE;YAC1B,OAAO,CAAC,CAAA;SACR;aAAM,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YACnD,OAAO,CAAC,CAAC,CAAA;SACT;aAAM,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YACnD,OAAO,CAAC,CAAA;SACR;aAAM;YACN,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SAC1D;IACF,CAAC;CACD,CAAA"}

View File

@@ -0,0 +1,87 @@
import { DifferenceType, Entry, Reason } from '..';
import { AsyncDiffSet } from '../compareAsync';
import { ExtOptions } from '../ExtOptions';
/**
* Compares two entries with identical name and type.
*/
export declare const EntryEquality: {
isEntryEqualSync(entry1: Entry, entry2: Entry, type: DifferenceType, options: ExtOptions): FileEquality;
isEntryEqualAsync(entry1: Entry, entry2: Entry, type: DifferenceType, asyncDiffSet: AsyncDiffSet, options: ExtOptions): FileEqualityPromise;
};
/**
* Response given when testing identically named files for equality during synchronous comparison.
*/
export type FileEquality = {
/**
* True if files are identical.
*/
same: boolean;
/**
* Provides reason if files are distinct
*/
reason?: Reason;
};
/**
* Response given when testing identically named files for equality during asynchronous comparison.
*/
export type FileEqualityPromise = FileEqualityPromiseSync | FileEqualityPromiseAsync;
/**
* Response given when testing identically named files for equality during asynchronous comparison.
*/
export type FileEqualityAsync = FileEqualityAsyncSuccess | FileEqualityAsyncError;
/**
* File equality response that represents a promise resolved synchronously.
* This can happen when files are compared by size avoiding async i/o calls.
*/
type FileEqualityPromiseSync = {
isSync: true;
/**
* True if files are identical.
*/
same: boolean;
/**
* Provides reason if files are distinct.
*/
reason?: Reason;
};
/**
* File equality response that represents a promise resolved asynchronously.
*/
type FileEqualityPromiseAsync = {
isSync: false;
fileEqualityAsyncPromise: Promise<FileEqualityAsync>;
};
/**
* Successful file equality test result.
*/
type FileEqualityAsyncSuccess = {
hasErrors: false;
/**
* True if files are identical.
*/
same: boolean;
/**
* Provides reason if files are distinct
*/
reason: Reason;
/**
* Provides comparison context during async operations.
*/
context: FileEqualityAsyncContext;
};
/**
* Failed file equality test result.
*/
type FileEqualityAsyncError = {
hasErrors: true;
error: unknown;
};
type FileEqualityAsyncContext = {
entry1: Entry;
entry2: Entry;
asyncDiffSet: AsyncDiffSet;
type1: DifferenceType;
type2: DifferenceType;
};
export {};
//# sourceMappingURL=EntryEquality.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryEquality.d.ts","sourceRoot":"","sources":["../../../src/Entry/EntryEquality.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,aAAa;6BACG,KAAK,UAAU,KAAK,QAAQ,cAAc,WAAW,UAAU,GAAG,YAAY;8BAa7E,KAAK,UAAU,KAAK,QAAQ,cAAc,uCAAuC,UAAU,GAAG,mBAAmB;CAa9I,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;EAEE;AACF,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,wBAAwB,CAAA;AAEpF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,GAAG,sBAAsB,CAAA;AAEjF;;;EAGE;AACF,KAAK,uBAAuB,GAAG;IAC3B,MAAM,EAAE,IAAI,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B,MAAM,EAAE,KAAK,CAAA;IACb,wBAAwB,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACvD,CAAA;AAED;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B,SAAS,EAAE,KAAK,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,wBAAwB,CAAA;CACpC,CAAA;AAED;;GAEG;AACH,KAAK,sBAAsB,GAAG;IAC1B,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC5B,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,KAAK,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,cAAc,CAAA;CACxB,CAAA"}

View File

@@ -0,0 +1,127 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryEquality = void 0;
const fs_1 = __importDefault(require("fs"));
/**
* Compares two entries with identical name and type.
*/
exports.EntryEquality = {
isEntryEqualSync(entry1, entry2, type, options) {
if (type === 'file') {
return isFileEqualSync(entry1, entry2, options);
}
if (type === 'directory') {
return isDirectoryEqual(entry1, entry2, options);
}
if (type === 'broken-link') {
return isBrokenLinkEqual();
}
throw new Error('Unexpected type ' + type);
},
isEntryEqualAsync(entry1, entry2, type, asyncDiffSet, options) {
if (type === 'file') {
return isFileEqualAsync(entry1, entry2, type, asyncDiffSet, options);
}
if (type === 'directory') {
return Object.assign({ isSync: true }, isDirectoryEqual(entry1, entry2, options));
}
if (type === 'broken-link') {
return Object.assign({ isSync: true }, isBrokenLinkEqual());
}
throw new Error('Unexpected type ' + type);
},
};
function isFileEqualSync(entry1, entry2, options) {
if (options.compareSymlink && !isSymlinkEqual(entry1, entry2)) {
return { same: false, reason: 'different-symlink' };
}
if (options.compareSize && entry1.stat.size !== entry2.stat.size) {
return { same: false, reason: 'different-size' };
}
if (options.compareDate && !isDateEqual(entry1.stat.mtime, entry2.stat.mtime, options.dateTolerance)) {
return { same: false, reason: 'different-date' };
}
if (options.compareContent && !options.compareFileSync(entry1.absolutePath, entry1.stat, entry2.absolutePath, entry2.stat, options)) {
return { same: false, reason: 'different-content' };
}
return { same: true };
}
function isFileEqualAsync(entry1, entry2, type, asyncDiffSet, options) {
if (options.compareSymlink && !isSymlinkEqual(entry1, entry2)) {
return { isSync: true, same: false, reason: 'different-symlink' };
}
if (options.compareSize && entry1.stat.size !== entry2.stat.size) {
return { isSync: true, same: false, reason: 'different-size' };
}
if (options.compareDate && !isDateEqual(entry1.stat.mtime, entry2.stat.mtime, options.dateTolerance)) {
return { isSync: true, same: false, reason: 'different-date' };
}
if (options.compareContent) {
let subDiffSet;
if (!options.noDiffSet) {
subDiffSet = [];
asyncDiffSet.push(subDiffSet);
}
const samePromise = options.compareFileAsync(entry1.absolutePath, entry1.stat, entry2.absolutePath, entry2.stat, options)
.then((comparisonResult) => {
if (typeof (comparisonResult) !== "boolean") {
return {
hasErrors: true,
error: comparisonResult
};
}
const same = comparisonResult;
const reason = same ? undefined : 'different-content';
return {
hasErrors: false,
same, reason,
context: {
entry1, entry2,
type1: type, type2: type,
asyncDiffSet: subDiffSet,
}
};
})
.catch((error) => ({
hasErrors: true,
error
}));
return { isSync: false, fileEqualityAsyncPromise: samePromise };
}
return { isSync: true, same: true };
}
function isDirectoryEqual(entry1, entry2, options) {
if (options.compareSymlink && !isSymlinkEqual(entry1, entry2)) {
return { same: false, reason: 'different-symlink' };
}
return { same: true, reason: undefined };
}
function isBrokenLinkEqual() {
return { same: false, reason: 'broken-link' }; // broken links are never considered equal
}
/**
* Compares two dates and returns true/false depending on tolerance (milliseconds).
* Two dates are considered equal if the difference in milliseconds between them is less or equal than tolerance.
*/
function isDateEqual(date1, date2, tolerance) {
return Math.abs(date1.getTime() - date2.getTime()) <= tolerance ? true : false;
}
/**
* Compares two entries for symlink equality.
*/
function isSymlinkEqual(entry1, entry2) {
if (!entry1.isSymlink && !entry2.isSymlink) {
return true;
}
if (entry1.isSymlink && entry2.isSymlink && hasIdenticalLink(entry1.absolutePath, entry2.absolutePath)) {
return true;
}
return false;
}
function hasIdenticalLink(path1, path2) {
return fs_1.default.readlinkSync(path1) === fs_1.default.readlinkSync(path2);
}
//# sourceMappingURL=EntryEquality.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryEquality.js","sourceRoot":"","sources":["../../../src/Entry/EntryEquality.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAKnB;;GAEG;AACU,QAAA,aAAa,GAAG;IACzB,gBAAgB,CAAC,MAAa,EAAE,MAAa,EAAE,IAAoB,EAAE,OAAmB;QACpF,IAAI,IAAI,KAAK,MAAM,EAAE;YACjB,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;SAClD;QACD,IAAI,IAAI,KAAK,WAAW,EAAE;YACtB,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE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CAAC,EAAE;QAC3D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;KACtD;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;AAC5C,CAAC;AAED,SAAS,iBAAiB;IACtB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA,CAAC,0CAA0C;AAC5F,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,KAAW,EAAE,KAAW,EAAE,SAAiB;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;AAClF,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,MAAa,EAAE,MAAa;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACxC,OAAO,IAAI,CAAA;KACd;IACD,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE;QACpG,OAAO,IAAI,CAAA;KACd;IACD,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa,EAAE,KAAa;IAClD,OAAO,YAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,YAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC"}

View File

@@ -0,0 +1,9 @@
import { DifferenceType, Entry } from "..";
export type OptionalEntry = Entry | undefined;
export declare const EntryType: {
/**
* One of 'missing','file','directory','broken-link'
*/
getType(entry: OptionalEntry): DifferenceType;
};
//# sourceMappingURL=EntryType.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryType.d.ts","sourceRoot":"","sources":["../../../src/Entry/EntryType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,IAAI,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC;AAE9C,eAAO,MAAM,SAAS;IACrB;;OAEG;mBACa,aAAa,GAAG,cAAc;CAY9C,CAAA"}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryType = void 0;
exports.EntryType = {
/**
* One of 'missing','file','directory','broken-link'
*/
getType(entry) {
if (!entry) {
return 'missing';
}
if (entry.isBrokenLink) {
return 'broken-link';
}
if (entry.isDirectory) {
return 'directory';
}
return 'file';
}
};
//# sourceMappingURL=EntryType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EntryType.js","sourceRoot":"","sources":["../../../src/Entry/EntryType.ts"],"names":[],"mappings":";;;AAIa,QAAA,SAAS,GAAG;IACxB;;OAEG;IACH,OAAO,CAAE,KAAoB;QAC5B,IAAI,CAAC,KAAK,EAAE;YACX,OAAO,SAAS,CAAA;SAChB;QACD,IAAI,KAAK,CAAC,YAAY,EAAE;YACvB,OAAO,aAAa,CAAA;SACpB;QACD,IAAI,KAAK,CAAC,WAAW,EAAE;YACtB,OAAO,WAAW,CAAA;SAClB;QACD,OAAO,MAAM,CAAA;IACd,CAAC;CACD,CAAA"}

View File

@@ -0,0 +1,14 @@
import { CompareFileAsync, CompareFileSync, CompareNameHandler, FilterHandler, Options, ResultBuilder } from "./types";
/**
* Clone of {@link Options} where fields with default values are
* expressed as non optional.
*/
export interface ExtOptions extends Options {
dateTolerance: number;
resultBuilder: ResultBuilder;
compareFileSync: CompareFileSync;
compareFileAsync: CompareFileAsync;
compareNameHandler: CompareNameHandler;
filterHandler: FilterHandler;
}
//# sourceMappingURL=ExtOptions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExtOptions.d.ts","sourceRoot":"","sources":["../../src/ExtOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGvH;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO;IACvC,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,eAAe,CAAA;IAChC,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,kBAAkB,EAAE,kBAAkB,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;CAC/B"}

View File

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

View File

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

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":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAUhD,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAA"}

View File

@@ -0,0 +1,112 @@
"use strict";
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 FileDescriptorQueue_1 = require("../../FileSystem/FileDescriptorQueue");
const BufferPool_1 = require("../../FileSystem/BufferPool");
const FileCloser_1 = require("../../FileSystem/FileCloser");
const FsPromise_1 = require("../../FileSystem/FsPromise");
const MAX_CONCURRENT_FILE_COMPARE = 8;
const BUF_SIZE = 1000000;
const fdQueue = new FileDescriptorQueue_1.FileDescriptorQueue(MAX_CONCURRENT_FILE_COMPARE * 2);
const asyncBufferPool = 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 syncBufferPool = new BufferPool_1.BufferPool(BUF_SIZE, 2);
exports.defaultFileCompare = {
compareSync, compareAsync
};
/**
* Compares two files by content.
*/
function compareSync(path1, stat1, path2, stat2, options) {
let fd1;
let fd2;
if (stat1.size !== stat2.size) {
return false;
}
const bufferPair = syncBufferPool.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 {
FileCloser_1.FileCloser.closeFilesSync(fd1, fd2);
syncBufferPool.freeBuffers(bufferPair);
}
}
/**
* Compares two files by content
*/
function compareAsync(path1, stat1, path2, stat2, options) {
let fd1;
let fd2;
let bufferPair;
if (stat1.size !== stat2.size) {
return Promise.resolve(false);
}
if (stat1.size < BUF_SIZE && !options.forceAsyncContentCompare) {
return Promise.resolve(compareSync(path1, stat1, path2, stat2, options));
}
return Promise.all([fdQueue.openPromise(path1, 'r'), fdQueue.openPromise(path2, 'r')])
.then(fds => {
bufferPair = asyncBufferPool.allocateBuffers();
fd1 = fds[0];
fd2 = fds[1];
const buf1 = bufferPair.buf1;
const buf2 = bufferPair.buf2;
const compareAsyncInternal = () => {
return Promise.all([
FsPromise_1.FsPromise.read(fd1, buf1, 0, BUF_SIZE, null),
FsPromise_1.FsPromise.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 buf1.slice(0, contentSize).equals(buf2.slice(0, contentSize));
}
function finalizeAsync(fd1, fd2, bufferPair) {
if (bufferPair) {
asyncBufferPool.freeBuffers(bufferPair);
}
return FileCloser_1.FileCloser.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,8EAA0E;AAC1E,4DAAoE;AAGpE,4DAAwD;AACxD,0DAAsD;AAEtD,MAAM,2BAA2B,GAAG,CAAC,CAAA;AACrC,MAAM,QAAQ,GAAG,OAAO,CAAA;AACxB,MAAM,OAAO,GAAG,IAAI,yCAAmB,CAAC,2BAA2B,GAAG,CAAC,CAAC,CAAA;AACxE,MAAM,eAAe,GAAG,IAAI,uBAAU,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA,CAAE,+HAA+H;AAC9M,MAAM,cAAc,GAAG,IAAI,uBAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AAErC,QAAA,kBAAkB,GAAuB;IAClD,WAAW,EAAE,YAAY;CAC5B,CAAA;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAa,EAAE,KAAe,EAAE,KAAa,EAAE,KAAe,EAAE,OAAgB;I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,IAAI,KAAK,KAAK,KAAK,EAAE;oBACjB,OAAO,KAAK,CAAA;iBACf;qBAAM,IAAI,KAAK,KAAK,CAAC,EAAE;oBACpB,sBAAsB;oBACtB,OAAO,IAAI,CAAA;iBACd;qBAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE;oBAC3C,OAAO,KAAK,CAAA;iBACf;qBAAM;oBACH,OAAO,oBAAoB,EAAE,CAAA;iBAChC;YACL,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;QACD,OAAO,oBAAoB,EAAE,CAAA;IACjC,CAAC,CAAC;SACD,IAAI;IACD,0CAA0C;IAC1C,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAC1D,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,CAAA,CAAC,CAAC,CAAC,CACvE,CAAA;AACT,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,WAAmB;IACnE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,SAAS,aAAa,CAAC,GAAY,EAAE,GAAY,EAAE,UAAuB;IACtE,IAAI,UAAU,EAAE;QACZ,eAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;KAC1C;IACD,OAAO,uBAAU,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;AACxD,CAAC"}

View File

@@ -0,0 +1,36 @@
import { BufferPair } from '../../FileSystem/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,6BAA6B,CAAA;AAExD,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 = (0, 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,IAAA,2BAAY,EAAC,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,MAAM,CAAC,MAAM,CAAC,CAAA;IAClD,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1D,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAA;SAC5D;KACJ;IACD,OAAO;QACH,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KAC9B,CAAA;AACL,CAAC;AAlBD,oCAkBC;AAGD,SAAS,WAAW,CAAC,OAAgB,EAAE,KAAa,EAAE,KAAa;IAC/D,IAAI,OAAO,CAAC,gBAAg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CAAC,MAAM,CAAA;IACpB,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;QACrB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;YACrB,OAAO;gBACH,UAAU,EAAE,MAAM;gBAClB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;aAC/B,CAAA;SACJ;QAED;YACI,UAAU,GAAG,IAAI,CAAA;YACjB,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAA;SAChC;KACJ;IACD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA;AAClC,CAAC"}

View File

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

View File

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

View File

@@ -0,0 +1,72 @@
"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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lineBasedCompareAsync = void 0;
const FileDescriptorQueue_1 = require("../../FileSystem/FileDescriptorQueue");
const LineBasedCompareContext_1 = require("./LineBasedCompareContext");
const BufferPool_1 = require("../../FileSystem/BufferPool");
const compareLineBatches_1 = require("./compare/compareLineBatches");
const readBufferedLines_1 = require("./lineReader/readBufferedLines");
const FileCloser_1 = require("../../FileSystem/FileCloser");
const FsPromise_1 = require("../../FileSystem/FsPromise");
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 = (0, 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 FileCloser_1.FileCloser.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.FsPromise.read(fd, buf, 0, bufferSize, null);
return (0, readBufferedLines_1.readBufferedLines)(buf, size, bufferSize, rest, restLines);
});
}
//# sourceMappingURL=lineBasedCompareAsync.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lineBasedCompareAsync.js","sourceRoot":"","sources":["../../../../src/FileCompareHandler/lines/lineBasedCompareAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAA0E;AAI1E,uEAAmE;AACnE,4DAAwD;AACxD,qEAAiE;AACjE,sEAAkE;AAElE,4DAAwD;AACxD,0DAAsD;AAEtD,MAAM,QAAQ,GAAG,MAAM,CAAA;AACvB,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAErC,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;AAElM,MAAM,qBAAqB,GAAqB,CAAO,KAAa,EAAE,KAAe,EAAE,KAAa,EAAE,KAAe,EAAE,OAAgB,EAAoB,EAAE;;IAChK,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAA,OAAO,CAAC,0BAA0B,mCAAI,MAAM,CAAC,SAAS,CAA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C,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAA;SACpE;KACJ;YAAS;QACN,IAAI,OAAO,EAAE;YACT,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACtC,MAAM,uBAAU,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;SACtE;KACJ;AACL,CAAC,CAAA,CAAA;AA/BY,QAAA,qBAAqB,yBA+BjC;AAED;;;;;;;;;;GAUG;AACH,SAAe,kBAAkB,CAAC,EAAU,EAAE,GAAW,EAAE,UAAkB,EAAE,IAAY,EAAE,SAAmB;;QAC5G,MAAM,IAAI,GAAG,MAAM,qBAAS,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QAC/D,OAAO,IAAA,qCAAiB,EAAC,GAAG,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=lineBasedCompareSync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lineBasedCompareSync.d.ts","sourceRoot":"","sources":["../../../../src/FileCompareHandler/lines/lineBasedCompareSync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAW7C,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 LineBasedCompareContext_1 = require("./LineBasedCompareContext");
const compareLineBatches_1 = require("./compare/compareLineBatches");
const readBufferedLines_1 = require("./lineReader/readBufferedLines");
const FileCloser_1 = require("../../FileSystem/FileCloser");
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 = (0, 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 {
FileCloser_1.FileCloser.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 (0, readBufferedLines_1.readBufferedLines)(buf, size, bufferSize, rest, restLines);
}
//# sourceMappingURL=lineBasedCompareSync.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lineBasedCompareSync.js","sourceRoot":"","sources":["../../../../src/FileCompareHandler/lines/lineBasedCompareSync.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAEnB,uEAAmE;AACnE,qEAAiE;AACjE,sEAAkE;AAIlE,4DAAwD;AAExD,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,MAAM,CAAC,SAAS,CAAC,CAAA;IAC7F,IAAI,OAA4C,CAAA;IAChD,IAAI;QACA,OAAO,GAAG,IAAI,iDAAuB,CACjC,YAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,EACvB,YAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,EACvB,UAAU,CACb,CAAA;QACD,SAAU;YACN,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;YACpI,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;YAEpI,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAA;YACpC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAA;YAEpC,MAAM,aAAa,GAAG,IAAA,uCAAkB,EAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;YACzE,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;gBAC7B,OAAO,KAAK,CAAA;aACf;YACD,IAAI,aAAa,CAAC,UAAU,EAAE;gBAC1B,OAAO,aAAa,CAAC,YAAY,CAAA;aACpC;YAED,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAA;YACjE,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAA;SACpE;KACJ;YAAS;QACN,uBAAU,CAAC,cAAc,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,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,IAAA,qCAAiB,EAAC,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 lineBasedCompareSync_1 = require("./lineBasedCompareSync");
const lineBasedCompareAsync_1 = require("./lineBasedCompareAsync");
/**
* Compare files line by line with options to ignore
* line endings and white space differences.
*/
exports.lineBasedFileCompare = {
compareSync: lineBasedCompareSync_1.lineBasedCompareSync,
compareAsync: lineBasedCompareAsync_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,iEAA2D;AAC3D,mEAA6D;AAG7D;;;GAGG;AACU,QAAA,oBAAoB,GAAuB;IACpD,WAAW,EAAE,2CAAoB;IACjC,YAAY,EAAE,6CAAqB;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"],"names":[],"mappings":";;;AAGA,MAAM,qBAAqB,GAAG,eAAe,CAAA;AAE7C;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAAC,GAAW,EAAE,IAAY,EAAE,mBAA2B,EAAE,IAAY,EAAE,SAAmB;IACvH,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACjC,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;KAC/D;IACD,IAAI,IAAI,KAAK,CAAC,EAAE;QACZ,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;KACrE;IAED,MAAM,WAAW,GAAG,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAa,CAAC,CAAA;IAErF,MAAM,UAAU,GAAG,IAAI,GAAG,mBAAmB,CAAA;IAC7C,IAAI,UAAU,EAAE;QACZ,OAAO;YACH,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI;SACpC,CAAA;KACJ;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC;AAnBD,8CAmBC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAAe;IACnC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACxC,OAAO;QACH,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACvC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,KAAK;KACpB,CAAA;AACL,CAAC"}

View File

@@ -0,0 +1,24 @@
/// <reference types="node" />
export interface BufferPair {
buf1: Buffer;
buf2: Buffer;
busy: boolean;
}
/**
* Collection of buffers to be shared between async processes.
* Avoids allocating buffers each time async process starts.
*/
export declare class BufferPool {
private readonly bufSize;
private readonly bufNo;
private readonly bufferPool;
/**
*
* @param bufSize Size of each buffer.
* @param bufNo Number of buffers. Caller has to make sure no more than bufNo async processes run simultaneously.
*/
constructor(bufSize: number, bufNo: number);
allocateBuffers(): BufferPair;
freeBuffers(bufferPair: BufferPair): void;
}
//# sourceMappingURL=BufferPool.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BufferPool.d.ts","sourceRoot":"","sources":["../../../src/FileSystem/BufferPool.ts"],"names":[],"mappings":";AAAA,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;CAChB;AAED;;;GAGG;AACH,qBAAa,UAAU;IAOP,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAU,OAAO,CAAC,QAAQ,CAAC,KAAK;IANpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C;;;;OAIG;gBAC0B,OAAO,EAAE,MAAM,EAAmB,KAAK,EAAE,MAAM;IAUrE,eAAe,IAAI,UAAU;IAW7B,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;CAGnD"}

View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BufferPool = void 0;
/**
* Collection of buffers to be shared between async processes.
* Avoids allocating buffers each time async process starts.
*/
class BufferPool {
/**
*
* @param bufSize Size of each buffer.
* @param bufNo Number of buffers. Caller has to make sure no more than bufNo async processes run simultaneously.
*/
constructor(bufSize, bufNo) {
this.bufSize = bufSize;
this.bufNo = bufNo;
this.bufferPool = [];
for (let i = 0; i < this.bufNo; i++) {
this.bufferPool.push({
buf1: Buffer.alloc(this.bufSize),
buf2: Buffer.alloc(this.bufSize),
busy: false
});
}
}
allocateBuffers() {
for (let j = 0; j < this.bufNo; j++) {
const bufferPair = this.bufferPool[j];
if (!bufferPair.busy) {
bufferPair.busy = true;
return bufferPair;
}
}
throw new Error('Async buffer limit reached');
}
freeBuffers(bufferPair) {
bufferPair.busy = false;
}
}
exports.BufferPool = BufferPool;
//# sourceMappingURL=BufferPool.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BufferPool.js","sourceRoot":"","sources":["../../../src/FileSystem/BufferPool.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,MAAa,UAAU;IAEnB;;;;OAIG;IACH,YAA6B,OAAe,EAAmB,KAAa;QAA/C,YAAO,GAAP,OAAO,CAAQ;QAAmB,UAAK,GAAL,KAAK,CAAQ;QAN3D,eAAU,GAAiB,EAAE,CAAA;QAO1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;gBAChC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;gBAChC,IAAI,EAAE,KAAK;aACd,CAAC,CAAA;SACL;IACL,CAAC;IAEM,eAAe;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;YACrC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;gBAClB,UAAU,CAAC,IAAI,GAAG,IAAI,CAAA;gBACtB,OAAO,UAAU,CAAA;aACpB;SACJ;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IACjD,CAAC;IAEM,WAAW,CAAC,UAAsB;QACrC,UAAU,CAAC,IAAI,GAAG,KAAK,CAAA;IAC3B,CAAC;CACJ;AA/BD,gCA+BC"}

View File

@@ -0,0 +1,9 @@
import { FileDescriptorQueue } from './FileDescriptorQueue';
declare function closeFilesSync(fd1?: number, fd2?: number): void;
declare function closeFilesAsync(fd1: number | undefined, fd2: number | undefined, fdQueue: FileDescriptorQueue): Promise<void>;
export declare const FileCloser: {
closeFilesSync: typeof closeFilesSync;
closeFilesAsync: typeof closeFilesAsync;
};
export {};
//# sourceMappingURL=FileCloser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileCloser.d.ts","sourceRoot":"","sources":["../../../src/FileSystem/FileCloser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,iBAAS,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAOxD;AAED,iBAAS,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtH;AAGD,eAAO,MAAM,UAAU;;;CAGtB,CAAA"}

View File

@@ -0,0 +1,32 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileCloser = void 0;
const fs_1 = __importDefault(require("fs"));
function closeFilesSync(fd1, fd2) {
if (fd1) {
fs_1.default.closeSync(fd1);
}
if (fd2) {
fs_1.default.closeSync(fd2);
}
}
function closeFilesAsync(fd1, fd2, fdQueue) {
if (fd1 && fd2) {
return fdQueue.closePromise(fd1).then(() => fdQueue.closePromise(fd2));
}
if (fd1) {
return fdQueue.closePromise(fd1);
}
if (fd2) {
return fdQueue.closePromise(fd2);
}
return Promise.resolve();
}
exports.FileCloser = {
closeFilesSync,
closeFilesAsync
};
//# sourceMappingURL=FileCloser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileCloser.js","sourceRoot":"","sources":["../../../src/FileSystem/FileCloser.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAGnB,SAAS,cAAc,CAAC,GAAY,EAAE,GAAY;IAC9C,IAAI,GAAG,EAAE;QACL,YAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KACpB;IACD,IAAI,GAAG,EAAE;QACL,YAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KACpB;AACL,CAAC;AAED,SAAS,eAAe,CAAC,GAAuB,EAAE,GAAuB,EAAE,OAA4B;IACnG,IAAI,GAAG,IAAI,GAAG,EAAE;QACZ,OAAO,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;KACzE;IACD,IAAI,GAAG,EAAE;QACL,OAAO,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;KACnC;IACD,IAAI,GAAG,EAAE;QACL,OAAO,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;KACnC;IACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;AAC5B,CAAC;AAGY,QAAA,UAAU,GAAG;IACtB,cAAc;IACd,eAAe;CAClB,CAAA"}

View File

@@ -0,0 +1,30 @@
/// <reference types="node" />
/// <reference types="node" />
import { NoParamCallback } from 'fs';
type OpenFileFlags = string;
type OpenFileCallback = (err: NodeJS.ErrnoException | null, fd: number) => void;
/**
* Limits the number of concurrent file handlers.
* Use it as a wrapper over fs.open() and fs.close().
* Example:
* const fdQueue = new FileDescriptorQueue(8)
* fdQueue.open(path, flags, (err, fd) =>{
* ...
* fdQueue.close(fd, (err) =>{
* ...
* })
* })
*/
export declare class FileDescriptorQueue {
private maxFilesNo;
private activeCount;
private pendingJobs;
constructor(maxFilesNo: number);
open(path: string, flags: OpenFileFlags, callback: OpenFileCallback): void;
process(): void;
close(fd: number, callback: NoParamCallback): void;
openPromise(path: string, flags: OpenFileFlags): Promise<number>;
closePromise(fd: number): Promise<void>;
}
export {};
//# sourceMappingURL=FileDescriptorQueue.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileDescriptorQueue.d.ts","sourceRoot":"","sources":["../../../src/FileSystem/FileDescriptorQueue.ts"],"names":[],"mappings":";;AAAA,OAAW,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAGxC,KAAK,aAAa,GAAG,MAAM,CAAA;AAC3B,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;AAO/E;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB;IAGnB,OAAO,CAAC,UAAU;IAF9B,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,WAAW,CAAmB;gBAClB,UAAU,EAAE,MAAM;IAEtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAS1E,OAAO,IAAI,IAAI;IAQf,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI;IAMlD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAYhE,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWvC"}

View File

@@ -0,0 +1,73 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileDescriptorQueue = void 0;
const fs_1 = __importDefault(require("fs"));
const Queue_1 = require("./Queue");
/**
* Limits the number of concurrent file handlers.
* Use it as a wrapper over fs.open() and fs.close().
* Example:
* const fdQueue = new FileDescriptorQueue(8)
* fdQueue.open(path, flags, (err, fd) =>{
* ...
* fdQueue.close(fd, (err) =>{
* ...
* })
* })
*/
class FileDescriptorQueue {
constructor(maxFilesNo) {
this.maxFilesNo = maxFilesNo;
this.activeCount = 0;
this.pendingJobs = new Queue_1.Queue();
}
open(path, flags, callback) {
this.pendingJobs.enqueue({
path: path,
flags: flags,
callback: callback
});
this.process();
}
process() {
if (this.pendingJobs.getLength() > 0 && this.activeCount < this.maxFilesNo) {
const job = this.pendingJobs.dequeue();
this.activeCount++;
fs_1.default.open(job.path, job.flags, job.callback);
}
}
close(fd, callback) {
this.activeCount--;
fs_1.default.close(fd, callback);
this.process();
}
openPromise(path, flags) {
return new Promise((resolve, reject) => {
this.open(path, flags, (err, fd) => {
if (err) {
reject(err);
}
else {
resolve(fd);
}
});
});
}
closePromise(fd) {
return new Promise((resolve, reject) => {
this.close(fd, (err) => {
if (err) {
reject(err);
}
else {
resolve();
}
});
});
}
}
exports.FileDescriptorQueue = FileDescriptorQueue;
//# sourceMappingURL=FileDescriptorQueue.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileDescriptorQueue.js","sourceRoot":"","sources":["../../../src/FileSystem/FileDescriptorQueue.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAwC;AACxC,mCAA+B;AAU/B;;;;;;;;;;;GAWG;AACH,MAAa,mBAAmB;IAG/B,YAAoB,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;QAF9B,gBAAW,GAAG,CAAC,CAAA;QACf,gBAAW,GAAG,IAAI,aAAK,EAAO,CAAA;IACI,CAAC;IAE3C,IAAI,CAAC,IAAY,EAAE,KAAoB,EAAE,QAA0B;QAClE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,QAAQ;SAClB,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;IAED,OAAO;QACN,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE;YAC3E,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAS,CAAA;YAC7C,IAAI,CAAC,WAAW,EAAE,CAAA;YAClB,YAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;SAC1C;IACF,CAAC;IAED,KAAK,CAAC,EAAU,EAAE,QAAyB;QAC1C,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,YAAE,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACtB,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,KAAoB;QAC7C,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;gBAClC,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAA;iBACX;qBAAM;oBACN,OAAO,CAAC,EAAE,CAAC,CAAA;iBACX;YACF,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;IAED,YAAY,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5C,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;gBACtB,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAA;iBACX;qBAAM;oBACN,OAAO,EAAE,CAAA;iBACT;YACF,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AAnDD,kDAmDC"}

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
type BytesRead = number;
export declare const FsPromise: {
readdir(path: string): Promise<string[]>;
read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise<BytesRead>;
};
export {};
//# sourceMappingURL=FsPromise.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FsPromise.d.ts","sourceRoot":"","sources":["../../../src/FileSystem/FsPromise.ts"],"names":[],"mappings":";AAEA,KAAK,SAAS,GAAG,MAAM,CAAA;AAEvB,eAAO,MAAM,SAAS;kBACJ,MAAM,GAAG,QAAQ,MAAM,EAAE,CAAC;aAW/B,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,YAAY,MAAM,GAAG,IAAI,GAAG,QAAQ,SAAS,CAAC;CAWhH,CAAA"}

View File

@@ -0,0 +1,34 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FsPromise = void 0;
const fs_1 = __importDefault(require("fs"));
exports.FsPromise = {
readdir(path) {
return new Promise((resolve, reject) => {
fs_1.default.readdir(path, (err, files) => {
if (err) {
reject(err);
}
else {
resolve(files);
}
});
});
},
read(fd, buffer, offset, length, position) {
return new Promise((resolve, reject) => {
fs_1.default.read(fd, buffer, offset, length, position, (err, bytesRead) => {
if (err) {
reject(err);
}
else {
resolve(bytesRead);
}
});
});
},
};
//# sourceMappingURL=FsPromise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FsPromise.js","sourceRoot":"","sources":["../../../src/FileSystem/FsPromise.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAIN,QAAA,SAAS,GAAG;IACrB,OAAO,CAAC,IAAY;QAChB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,YAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBAC5B,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAA;iBACd;qBAAM;oBACH,OAAO,CAAC,KAAK,CAAC,CAAA;iBACjB;YACL,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;IACD,IAAI,CAAC,EAAU,EAAE,MAAc,EAAE,MAAc,EAAE,MAAc,EAAE,QAAuB;QACpF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,YAAE,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;gBAC7D,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAA;iBACd;qBAAM;oBACH,OAAO,CAAC,SAAS,CAAC,CAAA;iBACrB;YACL,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;CACJ,CAAA"}

View File

@@ -0,0 +1,8 @@
export declare class Queue<T> {
private queue;
private offset;
getLength(): number;
enqueue(item: T): void;
dequeue(): T | undefined;
}
//# sourceMappingURL=Queue.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../src/FileSystem/Queue.ts"],"names":[],"mappings":"AAkBA,qBAAa,KAAK,CAAC,CAAC;IAGlB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,MAAM,CAAI;IAGX,SAAS,IAAI,MAAM;IAQnB,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAOtB,OAAO,IAAI,CAAC,GAAG,SAAS;CAoBhC"}

View File

@@ -0,0 +1,57 @@
"use strict";
/*
Queue.js
A function to represent a queue
Created by Kate Morley - http://code.iamkate.com/ - and released under the terms
of the CC0 1.0 Universal legal code:
http://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Queue = void 0;
const MAX_UNUSED_ARRAY_SIZE = 10000;
/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
* items are added to the end of the queue and removed from the front.
*/
class Queue {
constructor() {
// Initialize the queue and offset
this.queue = [];
this.offset = 0;
}
// Returns the length of the queue.
getLength() {
return this.queue.length - this.offset;
}
/* Enqueues the specified item. The parameter is:
*
* item - the item to enqueue
*/
enqueue(item) {
this.queue.push(item);
}
/* Dequeues an item and returns it. If the queue is empty, the value
* 'undefined' is returned.
*/
dequeue() {
// if the queue is empty, return immediately
if (this.queue.length === 0) {
return undefined;
}
// store the item at the front of the queue
const item = this.queue[this.offset];
// increment the offset and remove the free space if necessary
if (++this.offset > MAX_UNUSED_ARRAY_SIZE) {
this.queue = this.queue.slice(this.offset);
this.offset = 0;
}
// return the dequeued item
return item;
}
}
exports.Queue = Queue;
//# sourceMappingURL=Queue.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../../src/FileSystem/Queue.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;EAWE;;;AAEF,MAAM,qBAAqB,GAAG,KAAK,CAAA;AAEnC;;GAEG;AACH,MAAa,KAAK;IAAlB;QAEE,kCAAkC;QAC1B,UAAK,GAAQ,EAAE,CAAA;QACf,WAAM,GAAG,CAAC,CAAA;IAsCpB,CAAC;IApCC,mCAAmC;IAC5B,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IACxC,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,IAAO;QACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED;;OAEG;IACI,OAAO;QAEZ,4CAA4C;QAC5C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,OAAO,SAAS,CAAA;SACjB;QAED,2CAA2C;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpC,8DAA8D;QAC9D,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,qBAAqB,EAAE;YACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC1C,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;SAChB;QAED,2BAA2B;QAC3B,OAAO,IAAI,CAAA;IAEb,CAAC;CACF;AA1CD,sBA0CC"}

View File

@@ -0,0 +1,6 @@
import { FilterHandler } from "../types";
/**
* Default filter handler that uses minimatch to accept/ignore files based on includeFilter and excludeFilter options.
*/
export declare const defaultFilterHandler: FilterHandler;
//# sourceMappingURL=defaultFilterHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultFilterHandler.d.ts","sourceRoot":"","sources":["../../../src/FilterHandler/defaultFilterHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,aAAa,EAAE,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAYlC,CAAA"}

View File

@@ -0,0 +1,36 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultFilterHandler = void 0;
const path_1 = __importDefault(require("path"));
const minimatch_1 = __importDefault(require("minimatch"));
/**
* Default filter handler that uses minimatch to accept/ignore files based on includeFilter and excludeFilter options.
*/
const defaultFilterHandler = (entry, relativePath, options) => {
const path = path_1.default.join(relativePath, entry.name);
if ((entry.stat.isFile() && options.includeFilter) && (!match(path, options.includeFilter))) {
return false;
}
if ((options.excludeFilter) && (match(path, options.excludeFilter))) {
return false;
}
return true;
};
exports.defaultFilterHandler = defaultFilterHandler;
/**
* Matches path by pattern.
*/
function match(path, pattern) {
const patternArray = pattern.split(',');
for (let i = 0; i < patternArray.length; i++) {
const pat = patternArray[i];
if ((0, minimatch_1.default)(path, pat, { dot: true, matchBase: true })) { //nocase
return true;
}
}
return false;
}
//# sourceMappingURL=defaultFilterHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultFilterHandler.js","sourceRoot":"","sources":["../../../src/FilterHandler/defaultFilterHandler.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA4B;AAG5B,0DAAiC;AAEjC;;GAEG;AACI,MAAM,oBAAoB,GAAkB,CAAC,KAAY,EAAE,YAAoB,EAAE,OAAmB,EAAW,EAAE;IACpH,MAAM,IAAI,GAAG,cAAS,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAErD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE;QACzF,OAAO,KAAK,CAAA;KACf;IAED,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE;QACjE,OAAO,KAAK,CAAA;KACf;IAED,OAAO,IAAI,CAAA;AACf,CAAC,CAAA;AAZY,QAAA,oBAAoB,wBAYhC;AAED;;GAEG;AACH,SAAS,KAAK,CAAC,IAAY,EAAE,OAAe;IACxC,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;QAC3B,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ;YAChE,OAAO,IAAI,CAAA;SACd;KACJ;IACD,OAAO,KAAK,CAAA;AAChB,CAAC"}

View File

@@ -0,0 +1,2 @@
export type StringCompareResult = -1 | 0 | 1;
//# sourceMappingURL=StringCompareResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"StringCompareResult.d.ts","sourceRoot":"","sources":["../../../src/NameCompare/StringCompareResult.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
import { CompareNameHandler } from "../types";
/**
* The default implementation uses the 'strcmp' function for comparing file or directory names.
*/
export declare const defaultNameCompare: CompareNameHandler;
//# sourceMappingURL=defaultNameCompare.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultNameCompare.d.ts","sourceRoot":"","sources":["../../../src/NameCompare/defaultNameCompare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAMhC,CAAA"}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultNameCompare = void 0;
/**
* The default implementation uses the 'strcmp' function for comparing file or directory names.
*/
const defaultNameCompare = (name1, name2, options) => {
if (options.ignoreCase) {
name1 = name1.toLowerCase();
name2 = name2.toLowerCase();
}
return strcmp(name1, name2);
};
exports.defaultNameCompare = defaultNameCompare;
function strcmp(str1, str2) {
return ((str1 === str2) ? 0 : ((str1 > str2) ? 1 : -1));
}
//# sourceMappingURL=defaultNameCompare.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultNameCompare.js","sourceRoot":"","sources":["../../../src/NameCompare/defaultNameCompare.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACI,MAAM,kBAAkB,GAAuB,CAAC,KAAa,EAAE,KAAa,EAAE,OAAmB,EAAuB,EAAE;IAChI,IAAI,OAAO,CAAC,UAAU,EAAE;QACvB,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QAC3B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;KAC3B;IACD,OAAO,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,IAAY;IACzC,OAAO,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxD,CAAC"}

View File

@@ -0,0 +1,9 @@
import { ExtOptions } from "../ExtOptions";
import { StringCompareResult } from "./StringCompareResult";
/**
* Name comparator used when dir-compare is called to compare two files by content.
* In this case the file name is ignored (ie. comparing a1.txt and a2.txt
* will return true if file contents are identical).
*/
export declare function fileBasedNameCompare(name1: string, name2: string, options: ExtOptions): StringCompareResult;
//# sourceMappingURL=fileBasedNameCompare.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fileBasedNameCompare.d.ts","sourceRoot":"","sources":["../../../src/NameCompare/fileBasedNameCompare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,mBAAmB,CAE3G"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fileBasedNameCompare = void 0;
/**
* Name comparator used when dir-compare is called to compare two files by content.
* In this case the file name is ignored (ie. comparing a1.txt and a2.txt
* will return true if file contents are identical).
*/
function fileBasedNameCompare(name1, name2, options) {
return 0;
}
exports.fileBasedNameCompare = fileBasedNameCompare;
//# sourceMappingURL=fileBasedNameCompare.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fileBasedNameCompare.js","sourceRoot":"","sources":["../../../src/NameCompare/fileBasedNameCompare.ts"],"names":[],"mappings":";;;AAGA;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAAa,EAAE,KAAa,EAAE,OAAmB;IACrF,OAAO,CAAC,CAAA;AACT,CAAC;AAFD,oDAEC"}

View File

@@ -0,0 +1,7 @@
import { Entry, PermissionDeniedState } from "../types";
export declare const Permission: {
getPermissionDeniedState(entry1: Entry, entry2: Entry): PermissionDeniedState;
getPermissionDeniedStateWhenLeftMissing(entry2: Entry): PermissionDeniedState;
getPermissionDeniedStateWhenRightMissing(entry1: Entry): PermissionDeniedState;
};
//# sourceMappingURL=Permission.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Permission.d.ts","sourceRoot":"","sources":["../../../src/Permission/Permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEvD,eAAO,MAAM,UAAU;qCACc,KAAK,UAAU,KAAK,GAAG,qBAAqB;oDAW7B,KAAK,GAAG,qBAAqB;qDAO5B,KAAK,GAAG,qBAAqB;CAOjF,CAAA"}

Some files were not shown because too many files have changed in this diff Show More