adding suport for CRC32 SFV

This commit is contained in:
Metazla
2024-04-06 11:48:18 +02:00
parent dcc51bf41d
commit e28f924837
28 changed files with 353 additions and 172 deletions
@@ -1,35 +1,44 @@
import { BinaryLike } from 'crypto';
interface MultiHashData {
"cid_sha2-256"?: string;
cid_sha1?: string;
cid_md5?: string;
"cid_sha3-256"?: string;
cid_crc32?: string;
}
interface ComputeInterface {
computeMissingHash(filePath: string, metadata: MultiHashData): Promise<void>;
}
/**
* according to
* https://ipfs.io/ipfs/QmXec1jjwzxWJoNbxQF5KffL8q6hFXm9QwUGaa3wKGk6dT/#title=Multicodecs&src=https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv
*/
declare enum CID_ALGORITHM_CODES {
sha256 = 18,
sha1 = 17,
crc32 = 306,
md5 = 213,
sha3_256 = 22
sha1 = 17,
sha256 = 18,
sha3_256 = 22,
sha3_384 = 21
}
declare enum CID_ALGORITHM_NAMES {
sha256 = "cid_sha2-256",
sha1 = "cid_sha1",
crc32 = "cid_crc32",
md5 = "cid_md5",
sha3_256 = "cid_sha3-256"
sha1 = "cid_sha1",
sha256 = "cid_sha2-256",
sha3_256 = "cid_sha3-256",
sha3_384 = "cid_sha3-384"
}
declare enum CID_ALGORITHM {
sha256 = "sha2-256",
sha1 = "sha1",
crc32 = "crc32",
md5 = "md5",
sha3_256 = "sha3-256"
sha1 = "sha1",
sha256 = "sha2-256",
sha3_256 = "sha3-256",
sha3_384 = "sha3-384"
}
interface SimpleHash {
update(data: BinaryLike): any;
update(data: Buffer): any;
digest(): Buffer;
}
/**
@@ -1,35 +1,44 @@
import { BinaryLike } from 'crypto';
interface MultiHashData {
"cid_sha2-256"?: string;
cid_sha1?: string;
cid_md5?: string;
"cid_sha3-256"?: string;
cid_crc32?: string;
}
interface ComputeInterface {
computeMissingHash(filePath: string, metadata: MultiHashData): Promise<void>;
}
/**
* according to
* https://ipfs.io/ipfs/QmXec1jjwzxWJoNbxQF5KffL8q6hFXm9QwUGaa3wKGk6dT/#title=Multicodecs&src=https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv
*/
declare enum CID_ALGORITHM_CODES {
sha256 = 18,
sha1 = 17,
crc32 = 306,
md5 = 213,
sha3_256 = 22
sha1 = 17,
sha256 = 18,
sha3_256 = 22,
sha3_384 = 21
}
declare enum CID_ALGORITHM_NAMES {
sha256 = "cid_sha2-256",
sha1 = "cid_sha1",
crc32 = "cid_crc32",
md5 = "cid_md5",
sha3_256 = "cid_sha3-256"
sha1 = "cid_sha1",
sha256 = "cid_sha2-256",
sha3_256 = "cid_sha3-256",
sha3_384 = "cid_sha3-384"
}
declare enum CID_ALGORITHM {
sha256 = "sha2-256",
sha1 = "sha1",
crc32 = "crc32",
md5 = "md5",
sha3_256 = "sha3-256"
sha1 = "sha1",
sha256 = "sha2-256",
sha3_256 = "sha3-256",
sha3_384 = "sha3-384"
}
interface SimpleHash {
update(data: BinaryLike): any;
update(data: Buffer): any;
digest(): Buffer;
}
/**
+20
View File
@@ -0,0 +1,20 @@
'use strict';
var fs = require('fs');
var crypto = require('crypto');
var cid = require('multiformats/cid');
var digest = require('multiformats/hashes/digest');
var x = require('crc-32');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var x__default = /*#__PURE__*/_interopDefault(x);
var o=(s=>(s[s.crc32=306]="crc32",s[s.md5=213]="md5",s[s.sha1=17]="sha1",s[s.sha256=18]="sha256",s[s.sha3_256=22]="sha3_256",s[s.sha3_384=21]="sha3_384",s))(o||{}),n=(s=>(s.crc32="cid_crc32",s.md5="cid_md5",s.sha1="cid_sha1",s.sha256="cid_sha2-256",s.sha3_256="cid_sha3-256",s.sha3_384="cid_sha3-384",s))(n||{}),u=(s=>(s.crc32="crc32",s.md5="md5",s.sha1="sha1",s.sha256="sha2-256",s.sha3_256="sha3-256",s.sha3_384="sha3-384",s))(u||{});var t=class{_crc=void 0;update(a){return this._crc=x__default.default.buf(a,this._crc),this}digest(){console.log((this._crc>>>0).toString(16));let a=Buffer.alloc(4);return a.writeInt32BE(this._crc,0),a}};async function B({filePath:c,algorithms:a}){let h={"cid_sha2-256":{code:18,hasher:crypto.createHash("sha256")},cid_sha1:{code:17,hasher:crypto.createHash("sha1")},cid_md5:{code:213,hasher:crypto.createHash("md5")},"cid_sha3-256":{code:22,hasher:crypto.createHash("sha3-256")},"cid_sha3-384":{code:21,hasher:crypto.createHash("sha3-384")},cid_crc32:{code:306,hasher:new t}},i=a.map(s=>({hasher:h[s].hasher,code:h[s].code})),d=fs.createReadStream(c);for await(let s of d)for(let r of i)r.hasher.update(s);return await Promise.all(i.map(async({code:s,hasher:r})=>{let m=r.digest(),f=digest.create(s,m);return cid.CID.createV1(s,f).toString()}))}
exports.a = o;
exports.b = n;
exports.c = u;
exports.d = B;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-A5PD5ID4.cjs.map
+1
View File
File diff suppressed because one or more lines are too long
-15
View File
@@ -1,15 +0,0 @@
'use strict';
var fs = require('fs');
var crypto = require('crypto');
var cid = require('multiformats/cid');
var digest = require('multiformats/hashes/digest');
var i=(a=>(a[a.sha256=18]="sha256",a[a.sha1=17]="sha1",a[a.md5=213]="md5",a[a.sha3_256=22]="sha3_256",a))(i||{}),o=(a=>(a.sha256="cid_sha2-256",a.sha1="cid_sha1",a.md5="cid_md5",a.sha3_256="cid_sha3-256",a))(o||{}),f=(a=>(a.sha256="sha2-256",a.sha1="sha1",a.md5="md5",a.sha3_256="sha3-256",a))(f||{});async function x({filePath:c,algorithms:m}){let r={"cid_sha2-256":{code:18,hasher:crypto.createHash("sha256")},cid_sha1:{code:17,hasher:crypto.createHash("sha1")},cid_md5:{code:213,hasher:crypto.createHash("md5")},"cid_sha3-256":{code:22,hasher:crypto.createHash("sha3-256")}},h=m.map(s=>({hasher:r[s].hasher,code:r[s].code})),a=fs.createReadStream(c);for await(let s of a)for(let t of h)t.hasher.update(s);return await Promise.all(h.map(async({code:s,hasher:t})=>{let d=t.digest(),n=digest.create(s,d);return cid.CID.createV1(s,n).toString()}))}
exports.a = i;
exports.b = o;
exports.c = f;
exports.d = x;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-DL4KI2PZ.cjs.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"sources":["../src/lib/fileID/ShaComputeWorker.ts","../src/lib/MultiHashData.ts"],"names":["createReadStream","createHash","CID","create","CID_ALGORITHM_CODES","CID_ALGORITHM_NAMES","CID_ALGORITHM","computeCIDs","filePath","algorithms","hashFunctions","hashers","algo","stream","chunk","item","code","hasher","hashBuffer","digest"],"mappings":"AAAA,OAAS,oBAAAA,MAAwB,KACjC,OAAoB,cAAAC,MAAiB,SACrC,OAAS,OAAAC,MAAW,mBACpB,OAAS,UAAAC,MAAc,6BCShB,IAAKC,OACRA,IAAA,OAAS,IAAT,SACAA,IAAA,KAAO,IAAP,OACAA,IAAA,IAAM,KAAN,MACAA,IAAA,SAAW,IAAX,WAJQA,OAAA,IAQAC,OACRA,EAAA,OAAS,eACTA,EAAA,KAAO,WACPA,EAAA,IAAM,UACNA,EAAA,SAAW,eAJHA,OAAA,IAQAC,OACRA,EAAA,OAAS,WACTA,EAAA,KAAO,OACPA,EAAA,IAAM,MACNA,EAAA,SAAW,WAJHA,OAAA,IDVZ,eAAOC,EAAmC,CAAE,SAAAC,EAAU,WAAAC,CAAW,EAA+E,CAC5I,IAAMC,EACA,CACD,eAA6B,CAAE,QAAkC,OAAQT,EAAW,QAAQ,CAAE,EAC9F,SAA2B,CAAE,QAAgC,OAAQA,EAAW,MAAM,CAAE,EACxF,QAA0B,CAAE,SAA+B,OAAQA,EAAW,KAAK,CAAE,EACrF,eAA+B,CAAE,QAAoC,OAAOA,EAAW,UAAU,CAAE,CACxG,EAEMU,EAAUF,EAAW,IAAIG,IAAS,CACpC,OAAQF,EAAcE,CAAI,EAAE,OAC5B,KAAMF,EAAcE,CAAI,EAAE,IAC9B,EAAE,EAEIC,EAASb,EAAiBQ,CAAQ,EACxC,cAAiBM,KAASD,EACtB,QAAWE,KAAQJ,EACfI,EAAK,OAAO,OAAOD,CAAK,EAUhC,OANa,MAAM,QAAQ,IAAIH,EAAQ,IAAI,MAAO,CAAE,KAAAK,EAAM,OAAAC,CAAO,IAAM,CACnE,IAAMC,EAAaD,EAAO,OAAO,EAC3BE,EAAShB,EAAOa,EAAME,CAAU,EACtC,OAAOhB,EAAI,SAASc,EAAMG,CAAM,EAAE,SAAS,CAC/C,CAAC,CAAC,CAGN","sourcesContent":["import { createReadStream } from \"fs\";\nimport {BinaryLike, createHash} from 'crypto';\nimport { CID } from 'multiformats/cid';\nimport { create } from \"multiformats/hashes/digest\";\nimport {CID_ALGORITHM, CID_ALGORITHM_CODES, CID_ALGORITHM_NAMES} from \"../MultiHashData\";\n\nexport interface SimpleHash {\n update(data: BinaryLike),\n digest(): Buffer;\n}\n\n\n/**\n * Compute the CIDs of a file using specific algorithms\n * @param filePath The path to the file\n * @param algorithms Array of algorithms ('sha256', 'sha1')\n * @returns Array of CIDs (in the order of the algorithms)\n */\nexport default async function computeCIDs({ filePath, algorithms }: { filePath: string; algorithms: CID_ALGORITHM_NAMES[] }): Promise<string[]> {\n const hashFunctions: Record<string, { code: number, hasher: SimpleHash }>\n = {\n [CID_ALGORITHM_NAMES.sha256]: { code: CID_ALGORITHM_CODES.sha256, hasher: createHash('sha256') },\n [CID_ALGORITHM_NAMES.sha1]: { code: CID_ALGORITHM_CODES.sha1, hasher: createHash('sha1') },\n [CID_ALGORITHM_NAMES.md5]: { code: CID_ALGORITHM_CODES.md5, hasher: createHash('md5') },\n [CID_ALGORITHM_NAMES.sha3_256]: { code: CID_ALGORITHM_CODES.sha3_256, hasher:createHash('sha3-256') }\n };\n\n const hashers = algorithms.map(algo => ({\n hasher: hashFunctions[algo].hasher,\n code: hashFunctions[algo].code\n }));\n\n const stream = createReadStream(filePath);\n for await (const chunk of stream) {\n for (const item of hashers) {\n item.hasher.update(chunk);\n }\n }\n\n const cids = await Promise.all(hashers.map(async ({ code, hasher }) => {\n const hashBuffer = hasher.digest();\n const digest = create(code, hashBuffer);\n return CID.createV1(code, digest).toString();\n }));\n\n return cids;\n}\n","export interface MultiHashData {\n \"cid_sha2-256\"?: string;//0x12 sha2-256\n cid_sha1?: string; // 0x11 sha1\n cid_md5?: string; // 0xd5 md5\n \"cid_sha3-256\"?: string; // 0x16 sha3-256\n //cid_crc32?: string; //0x0132 CRC32 (SFV) TODO\n}\n\nexport interface ComputeInterface {\n computeMissingHash(filePath: string, metadata: MultiHashData): Promise<void>;\n}\n\nexport enum CID_ALGORITHM_CODES {\n sha256 = 0x12,\n sha1 = 0x11,\n md5 = 0xd5,\n sha3_256 = 0x16,\n //crc32 = 0x0132\n}\n\nexport enum CID_ALGORITHM_NAMES {\n sha256 = 'cid_sha2-256',\n sha1 = 'cid_sha1',\n md5 = 'cid_md5',\n sha3_256 = 'cid_sha3-256',\n //crc32 = 'cid_crc32'\n}\n\nexport enum CID_ALGORITHM {\n sha256 = 'sha2-256',\n sha1 = 'sha1',\n md5 = 'md5',\n sha3_256 = 'sha3-256',\n //crc32 = 'crc32'\n}"]}
+11
View File
@@ -0,0 +1,11 @@
import { createReadStream } from 'fs';
import { createHash } from 'crypto';
import { CID } from 'multiformats/cid';
import { create } from 'multiformats/hashes/digest';
import x from 'crc-32';
var o=(s=>(s[s.crc32=306]="crc32",s[s.md5=213]="md5",s[s.sha1=17]="sha1",s[s.sha256=18]="sha256",s[s.sha3_256=22]="sha3_256",s[s.sha3_384=21]="sha3_384",s))(o||{}),n=(s=>(s.crc32="cid_crc32",s.md5="cid_md5",s.sha1="cid_sha1",s.sha256="cid_sha2-256",s.sha3_256="cid_sha3-256",s.sha3_384="cid_sha3-384",s))(n||{}),u=(s=>(s.crc32="crc32",s.md5="md5",s.sha1="sha1",s.sha256="sha2-256",s.sha3_256="sha3-256",s.sha3_384="sha3-384",s))(u||{});var t=class{_crc=void 0;update(a){return this._crc=x.buf(a,this._crc),this}digest(){console.log((this._crc>>>0).toString(16));let a=Buffer.alloc(4);return a.writeInt32BE(this._crc,0),a}};async function B({filePath:c,algorithms:a}){let h={"cid_sha2-256":{code:18,hasher:createHash("sha256")},cid_sha1:{code:17,hasher:createHash("sha1")},cid_md5:{code:213,hasher:createHash("md5")},"cid_sha3-256":{code:22,hasher:createHash("sha3-256")},"cid_sha3-384":{code:21,hasher:createHash("sha3-384")},cid_crc32:{code:306,hasher:new t}},i=a.map(s=>({hasher:h[s].hasher,code:h[s].code})),d=createReadStream(c);for await(let s of d)for(let r of i)r.hasher.update(s);return await Promise.all(i.map(async({code:s,hasher:r})=>{let m=r.digest(),f=create(s,m);return CID.createV1(s,f).toString()}))}
export { o as a, n as b, u as c, B as d };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-FGATABDV.js.map
+1
View File
File diff suppressed because one or more lines are too long
-10
View File
@@ -1,10 +0,0 @@
import { createReadStream } from 'fs';
import { createHash } from 'crypto';
import { CID } from 'multiformats/cid';
import { create } from 'multiformats/hashes/digest';
var i=(a=>(a[a.sha256=18]="sha256",a[a.sha1=17]="sha1",a[a.md5=213]="md5",a[a.sha3_256=22]="sha3_256",a))(i||{}),o=(a=>(a.sha256="cid_sha2-256",a.sha1="cid_sha1",a.md5="cid_md5",a.sha3_256="cid_sha3-256",a))(o||{}),f=(a=>(a.sha256="sha2-256",a.sha1="sha1",a.md5="md5",a.sha3_256="sha3-256",a))(f||{});async function x({filePath:c,algorithms:m}){let r={"cid_sha2-256":{code:18,hasher:createHash("sha256")},cid_sha1:{code:17,hasher:createHash("sha1")},cid_md5:{code:213,hasher:createHash("md5")},"cid_sha3-256":{code:22,hasher:createHash("sha3-256")}},h=m.map(s=>({hasher:r[s].hasher,code:r[s].code})),a=createReadStream(c);for await(let s of a)for(let t of h)t.hasher.update(s);return await Promise.all(h.map(async({code:s,hasher:t})=>{let d=t.digest(),n=create(s,d);return CID.createV1(s,n).toString()}))}
export { i as a, o as b, f as c, x as d };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-VGBIRFOR.js.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"sources":["../src/lib/fileID/ShaComputeWorker.ts","../src/lib/MultiHashData.ts"],"names":["createReadStream","createHash","CID","create","CID_ALGORITHM_CODES","CID_ALGORITHM_NAMES","CID_ALGORITHM","computeCIDs","filePath","algorithms","hashFunctions","hashers","algo","stream","chunk","item","code","hasher","hashBuffer","digest"],"mappings":"AAAA,OAAS,oBAAAA,MAAwB,KACjC,OAAoB,cAAAC,MAAiB,SACrC,OAAS,OAAAC,MAAW,mBACpB,OAAS,UAAAC,MAAc,6BCShB,IAAKC,OACRA,IAAA,OAAS,IAAT,SACAA,IAAA,KAAO,IAAP,OACAA,IAAA,IAAM,KAAN,MACAA,IAAA,SAAW,IAAX,WAJQA,OAAA,IAQAC,OACRA,EAAA,OAAS,eACTA,EAAA,KAAO,WACPA,EAAA,IAAM,UACNA,EAAA,SAAW,eAJHA,OAAA,IAQAC,OACRA,EAAA,OAAS,WACTA,EAAA,KAAO,OACPA,EAAA,IAAM,MACNA,EAAA,SAAW,WAJHA,OAAA,IDVZ,eAAOC,EAAmC,CAAE,SAAAC,EAAU,WAAAC,CAAW,EAA+E,CAC5I,IAAMC,EACA,CACD,eAA6B,CAAE,QAAkC,OAAQT,EAAW,QAAQ,CAAE,EAC9F,SAA2B,CAAE,QAAgC,OAAQA,EAAW,MAAM,CAAE,EACxF,QAA0B,CAAE,SAA+B,OAAQA,EAAW,KAAK,CAAE,EACrF,eAA+B,CAAE,QAAoC,OAAOA,EAAW,UAAU,CAAE,CACxG,EAEMU,EAAUF,EAAW,IAAIG,IAAS,CACpC,OAAQF,EAAcE,CAAI,EAAE,OAC5B,KAAMF,EAAcE,CAAI,EAAE,IAC9B,EAAE,EAEIC,EAASb,EAAiBQ,CAAQ,EACxC,cAAiBM,KAASD,EACtB,QAAWE,KAAQJ,EACfI,EAAK,OAAO,OAAOD,CAAK,EAUhC,OANa,MAAM,QAAQ,IAAIH,EAAQ,IAAI,MAAO,CAAE,KAAAK,EAAM,OAAAC,CAAO,IAAM,CACnE,IAAMC,EAAaD,EAAO,OAAO,EAC3BE,EAAShB,EAAOa,EAAME,CAAU,EACtC,OAAOhB,EAAI,SAASc,EAAMG,CAAM,EAAE,SAAS,CAC/C,CAAC,CAAC,CAGN","sourcesContent":["import { createReadStream } from \"fs\";\nimport {BinaryLike, createHash} from 'crypto';\nimport { CID } from 'multiformats/cid';\nimport { create } from \"multiformats/hashes/digest\";\nimport {CID_ALGORITHM, CID_ALGORITHM_CODES, CID_ALGORITHM_NAMES} from \"../MultiHashData\";\n\nexport interface SimpleHash {\n update(data: BinaryLike),\n digest(): Buffer;\n}\n\n\n/**\n * Compute the CIDs of a file using specific algorithms\n * @param filePath The path to the file\n * @param algorithms Array of algorithms ('sha256', 'sha1')\n * @returns Array of CIDs (in the order of the algorithms)\n */\nexport default async function computeCIDs({ filePath, algorithms }: { filePath: string; algorithms: CID_ALGORITHM_NAMES[] }): Promise<string[]> {\n const hashFunctions: Record<string, { code: number, hasher: SimpleHash }>\n = {\n [CID_ALGORITHM_NAMES.sha256]: { code: CID_ALGORITHM_CODES.sha256, hasher: createHash('sha256') },\n [CID_ALGORITHM_NAMES.sha1]: { code: CID_ALGORITHM_CODES.sha1, hasher: createHash('sha1') },\n [CID_ALGORITHM_NAMES.md5]: { code: CID_ALGORITHM_CODES.md5, hasher: createHash('md5') },\n [CID_ALGORITHM_NAMES.sha3_256]: { code: CID_ALGORITHM_CODES.sha3_256, hasher:createHash('sha3-256') }\n };\n\n const hashers = algorithms.map(algo => ({\n hasher: hashFunctions[algo].hasher,\n code: hashFunctions[algo].code\n }));\n\n const stream = createReadStream(filePath);\n for await (const chunk of stream) {\n for (const item of hashers) {\n item.hasher.update(chunk);\n }\n }\n\n const cids = await Promise.all(hashers.map(async ({ code, hasher }) => {\n const hashBuffer = hasher.digest();\n const digest = create(code, hashBuffer);\n return CID.createV1(code, digest).toString();\n }));\n\n return cids;\n}\n","export interface MultiHashData {\n \"cid_sha2-256\"?: string;//0x12 sha2-256\n cid_sha1?: string; // 0x11 sha1\n cid_md5?: string; // 0xd5 md5\n \"cid_sha3-256\"?: string; // 0x16 sha3-256\n //cid_crc32?: string; //0x0132 CRC32 (SFV) TODO\n}\n\nexport interface ComputeInterface {\n computeMissingHash(filePath: string, metadata: MultiHashData): Promise<void>;\n}\n\nexport enum CID_ALGORITHM_CODES {\n sha256 = 0x12,\n sha1 = 0x11,\n md5 = 0xd5,\n sha3_256 = 0x16,\n //crc32 = 0x0132\n}\n\nexport enum CID_ALGORITHM_NAMES {\n sha256 = 'cid_sha2-256',\n sha1 = 'cid_sha1',\n md5 = 'cid_md5',\n sha3_256 = 'cid_sha3-256',\n //crc32 = 'cid_crc32'\n}\n\nexport enum CID_ALGORITHM {\n sha256 = 'sha2-256',\n sha1 = 'sha1',\n md5 = 'md5',\n sha3_256 = 'sha3-256',\n //crc32 = 'crc32'\n}"]}
+16 -16
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+6 -7
View File
@@ -1,9 +1,8 @@
import { C as ComputeInterface, a as CID_ALGORITHM_NAMES, M as MultiHashData } from './ShaComputeWorker-DWOF-qaH.cjs';
export { c as CID_ALGORITHM, b as CID_ALGORITHM_CODES, S as SimpleHash } from './ShaComputeWorker-DWOF-qaH.cjs';
import { C as ComputeInterface, a as CID_ALGORITHM_NAMES, M as MultiHashData } from './ShaComputeWorker-DxWHpwX4.cjs';
export { c as CID_ALGORITHM, b as CID_ALGORITHM_CODES, S as SimpleHash } from './ShaComputeWorker-DxWHpwX4.cjs';
import * as PQueue from 'p-queue';
import PQueue__default from 'p-queue';
import * as p_queue_dist_priority_queue_js from 'p-queue/dist/priority-queue.js';
import 'crypto';
declare class HashComputer implements ComputeInterface {
private targetHash;
@@ -19,7 +18,6 @@ interface IndexLine extends Partial<Record<CID_ALGORITHM_NAMES, string>> {
}
declare const INDEX_HEADERS: string[];
declare class HashIndexManager {
private filePath;
private targetHash;
private cache;
private intervalId;
@@ -29,18 +27,19 @@ declare class HashIndexManager {
private indexOpsInProgress;
private hasChanged;
private initialLoad;
private filePaths;
constructor(filePath: string, targetHash?: CID_ALGORITHM_NAMES[]);
getCache(): Map<string, IndexLine>;
/**
* After init consseutively calls to this method will not reload the index
* @param autosave
*/
init(autosave?: boolean): Promise<any>;
checkCSVHeaders(csvContent: string): boolean;
init(autosave?: boolean): Promise<void>;
private checkCSVHeaders;
start(): void;
stopAutoSave(): void;
private startAutoSave;
loadIndex(): Promise<IndexLine[]>;
loadIndex(hash: CID_ALGORITHM_NAMES): Promise<IndexLine[]>;
private loadIndexFromCache;
private readCsv;
private saveCacheToFile;
+6 -7
View File
@@ -1,9 +1,8 @@
import { C as ComputeInterface, a as CID_ALGORITHM_NAMES, M as MultiHashData } from './ShaComputeWorker-DWOF-qaH.js';
export { c as CID_ALGORITHM, b as CID_ALGORITHM_CODES, S as SimpleHash } from './ShaComputeWorker-DWOF-qaH.js';
import { C as ComputeInterface, a as CID_ALGORITHM_NAMES, M as MultiHashData } from './ShaComputeWorker-DxWHpwX4.js';
export { c as CID_ALGORITHM, b as CID_ALGORITHM_CODES, S as SimpleHash } from './ShaComputeWorker-DxWHpwX4.js';
import * as PQueue from 'p-queue';
import PQueue__default from 'p-queue';
import * as p_queue_dist_priority_queue_js from 'p-queue/dist/priority-queue.js';
import 'crypto';
declare class HashComputer implements ComputeInterface {
private targetHash;
@@ -19,7 +18,6 @@ interface IndexLine extends Partial<Record<CID_ALGORITHM_NAMES, string>> {
}
declare const INDEX_HEADERS: string[];
declare class HashIndexManager {
private filePath;
private targetHash;
private cache;
private intervalId;
@@ -29,18 +27,19 @@ declare class HashIndexManager {
private indexOpsInProgress;
private hasChanged;
private initialLoad;
private filePaths;
constructor(filePath: string, targetHash?: CID_ALGORITHM_NAMES[]);
getCache(): Map<string, IndexLine>;
/**
* After init consseutively calls to this method will not reload the index
* @param autosave
*/
init(autosave?: boolean): Promise<any>;
checkCSVHeaders(csvContent: string): boolean;
init(autosave?: boolean): Promise<void>;
private checkCSVHeaders;
start(): void;
stopAutoSave(): void;
private startAutoSave;
loadIndex(): Promise<IndexLine[]>;
loadIndex(hash: CID_ALGORITHM_NAMES): Promise<IndexLine[]>;
private loadIndexFromCache;
private readCsv;
private saveCacheToFile;
+6 -6
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,9 +1,9 @@
'use strict';
var chunkDL4KI2PZ_cjs = require('./chunk-DL4KI2PZ.cjs');
var chunkA5PD5ID4_cjs = require('./chunk-A5PD5ID4.cjs');
module.exports = chunkDL4KI2PZ_cjs.d;
module.exports = chunkA5PD5ID4_cjs.d;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=worker.cjs.map
+1 -2
View File
@@ -1,2 +1 @@
import 'crypto';
export { S as SimpleHash, d as default } from './ShaComputeWorker-DWOF-qaH.cjs';
export { S as SimpleHash, d as default } from './ShaComputeWorker-DxWHpwX4.cjs';
+1 -2
View File
@@ -1,2 +1 @@
import 'crypto';
export { S as SimpleHash, d as default } from './ShaComputeWorker-DWOF-qaH.js';
export { S as SimpleHash, d as default } from './ShaComputeWorker-DxWHpwX4.js';
+1 -1
View File
@@ -1,3 +1,3 @@
export { d as default } from './chunk-VGBIRFOR.js';
export { d as default } from './chunk-FGATABDV.js';
//# sourceMappingURL=out.js.map
//# sourceMappingURL=worker.js.map