imrprove hash
This commit is contained in:
Vendored
+28
-12
@@ -1,27 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
require('./chunk-KWYLOVWT.cjs');
|
||||
var chunk33LRP2HS_cjs = require('./chunk-33LRP2HS.cjs');
|
||||
var chunkPAKJNZBJ_cjs = require('./chunk-PAKJNZBJ.cjs');
|
||||
var chunkOHUFSPVO_cjs = require('./chunk-OHUFSPVO.cjs');
|
||||
var chunkS7BSPELE_cjs = require('./chunk-S7BSPELE.cjs');
|
||||
|
||||
var a=class{constructor(r){this.targetHash=r;}async computeMissingHash(r,e){let t=this.targetHash.filter(o=>!e[o]);if(t.length===0)return;let i=await chunk33LRP2HS_cjs.a({stream:r,algorithms:t});for(let[o,c]of i.entries()){let n=t[o];e[n]=c;}}};
|
||||
// src/lib/hash-compute/HashComputer.ts
|
||||
var HashComputer = class {
|
||||
constructor(targetHash) {
|
||||
this.targetHash = targetHash;
|
||||
}
|
||||
async computeMissingHash(stream, metadata) {
|
||||
const neededHashes = this.targetHash.filter((hashName) => !metadata[hashName]);
|
||||
if (neededHashes.length === 0) {
|
||||
return;
|
||||
}
|
||||
const cids = await chunkOHUFSPVO_cjs.computeCIDs({ stream, algorithms: neededHashes });
|
||||
for (const [index, cid] of cids.entries()) {
|
||||
const hashType = neededHashes[index];
|
||||
metadata[hashType] = cid;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, "computeCIDs", {
|
||||
enumerable: true,
|
||||
get: function () { return chunk33LRP2HS_cjs.a; }
|
||||
enumerable: true,
|
||||
get: function () { return chunkOHUFSPVO_cjs.computeCIDs; }
|
||||
});
|
||||
Object.defineProperty(exports, "CID_ALGORITHM", {
|
||||
enumerable: true,
|
||||
get: function () { return chunkPAKJNZBJ_cjs.c; }
|
||||
enumerable: true,
|
||||
get: function () { return chunkS7BSPELE_cjs.CID_ALGORITHM; }
|
||||
});
|
||||
Object.defineProperty(exports, "CID_ALGORITHM_CODES", {
|
||||
enumerable: true,
|
||||
get: function () { return chunkPAKJNZBJ_cjs.a; }
|
||||
enumerable: true,
|
||||
get: function () { return chunkS7BSPELE_cjs.CID_ALGORITHM_CODES; }
|
||||
});
|
||||
Object.defineProperty(exports, "CID_ALGORITHM_NAMES", {
|
||||
enumerable: true,
|
||||
get: function () { return chunkPAKJNZBJ_cjs.b; }
|
||||
enumerable: true,
|
||||
get: function () { return chunkS7BSPELE_cjs.CID_ALGORITHM_NAMES; }
|
||||
});
|
||||
exports.HashComputer = a;
|
||||
exports.HashComputer = HashComputer;
|
||||
//# sourceMappingURL=out.js.map
|
||||
//# sourceMappingURL=index-browser.cjs.map
|
||||
Reference in New Issue
Block a user