node-provenance-hash
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,4 +0,4 @@ | ||
export default function (sourceDirImages: string, sourceDirMetadata: string, sortingFunction?: (a: string, b: string) => number): Promise<{ | ||
imagesProvenanceHash: string; | ||
metadataProvenanceHash: string; | ||
export default function (sourceDirImages?: string, sourceDirMetadata?: string, sortingFunction?: (a: string, b: string) => number): Promise<{ | ||
imagesProvenanceHash: any; | ||
metadataProvenanceHash: any; | ||
}>; |
@@ -43,24 +43,25 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var jsonFiles, imageFiles, fullImgHash, _i, imageFiles_1, file, h, fullMetadataHash, _a, jsonFiles_1, file, h; | ||
var _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var hashes, jsonFiles, fullMetadataHash, _i, jsonFiles_1, file, h, _a, imageFiles, fullImgHash, _b, imageFiles_1, file, h, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
hashes = { | ||
imagesProvenanceHash: undefined, | ||
metadataProvenanceHash: undefined | ||
}; | ||
if (!sourceDirMetadata) return [3 /*break*/, 6]; | ||
jsonFiles = sortingFunction | ||
? (0, fs_1.readdirSync)(sourceDirMetadata) | ||
: (0, fs_1.readdirSync)(sourceDirMetadata).sort(sortingFunction); | ||
imageFiles = sortingFunction | ||
? (0, fs_1.readdirSync)(sourceDirImages) | ||
: (0, fs_1.readdirSync)(sourceDirImages).sort(sortingFunction); | ||
fullImgHash = ""; | ||
_i = 0, imageFiles_1 = imageFiles; | ||
_c.label = 1; | ||
fullMetadataHash = ""; | ||
_i = 0, jsonFiles_1 = jsonFiles; | ||
_d.label = 1; | ||
case 1: | ||
if (!(_i < imageFiles_1.length)) return [3 /*break*/, 4]; | ||
file = imageFiles_1[_i]; | ||
return [4 /*yield*/, hash(sourceDirImages + "/" + file, true)]; | ||
if (!(_i < jsonFiles_1.length)) return [3 /*break*/, 4]; | ||
file = jsonFiles_1[_i]; | ||
return [4 /*yield*/, hash(sourceDirMetadata + "/" + file, true)]; | ||
case 2: | ||
h = _c.sent(); | ||
fullImgHash += h; | ||
_c.label = 3; | ||
h = _d.sent(); | ||
fullMetadataHash += h; | ||
_d.label = 3; | ||
case 3: | ||
@@ -70,24 +71,33 @@ _i++; | ||
case 4: | ||
fullMetadataHash = ""; | ||
_a = 0, jsonFiles_1 = jsonFiles; | ||
_c.label = 5; | ||
_a = hashes; | ||
return [4 /*yield*/, hash(fullMetadataHash, false)]; | ||
case 5: | ||
if (!(_a < jsonFiles_1.length)) return [3 /*break*/, 8]; | ||
file = jsonFiles_1[_a]; | ||
return [4 /*yield*/, hash(sourceDirMetadata + "/" + file, true)]; | ||
_a.metadataProvenanceHash = _d.sent(); | ||
_d.label = 6; | ||
case 6: | ||
h = _c.sent(); | ||
fullMetadataHash += h; | ||
_c.label = 7; | ||
if (!sourceDirImages) return [3 /*break*/, 12]; | ||
imageFiles = sortingFunction | ||
? (0, fs_1.readdirSync)(sourceDirImages) | ||
: (0, fs_1.readdirSync)(sourceDirImages).sort(sortingFunction); | ||
fullImgHash = ""; | ||
_b = 0, imageFiles_1 = imageFiles; | ||
_d.label = 7; | ||
case 7: | ||
_a++; | ||
return [3 /*break*/, 5]; | ||
if (!(_b < imageFiles_1.length)) return [3 /*break*/, 10]; | ||
file = imageFiles_1[_b]; | ||
return [4 /*yield*/, hash(sourceDirImages + "/" + file, true)]; | ||
case 8: | ||
_b = {}; | ||
h = _d.sent(); | ||
fullImgHash += h; | ||
_d.label = 9; | ||
case 9: | ||
_b++; | ||
return [3 /*break*/, 7]; | ||
case 10: | ||
_c = hashes; | ||
return [4 /*yield*/, hash(fullImgHash, false)]; | ||
case 9: | ||
_b.imagesProvenanceHash = _c.sent(); | ||
return [4 /*yield*/, hash(fullMetadataHash, false)]; | ||
case 10: return [2 /*return*/, (_b.metadataProvenanceHash = _c.sent(), | ||
_b)]; | ||
case 11: | ||
_c.imagesProvenanceHash = _d.sent(); | ||
_d.label = 12; | ||
case 12: return [2 /*return*/, hashes]; | ||
} | ||
@@ -94,0 +104,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": { | ||
@@ -11,2 +11,5 @@ "email": "ttokic1985@gmail.com", | ||
}, | ||
"dependencies": { | ||
"node-provenance-hash": "^0.0.3" | ||
}, | ||
"scripts": { | ||
@@ -19,2 +22,7 @@ "build": "yarn tsc src/main.ts --outDir dist --declaration", | ||
"@types/node": "^16.11.7", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"eslint": "^8.4.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"prettier": "^2.4.1", | ||
@@ -21,0 +29,0 @@ "ts-node": "^10.4.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9816
130
1
9
+ Addednode-provenance-hash@^0.0.3
+ Addednode-provenance-hash@0.0.3(transitive)