本文整理匯總了TypeScript中@es-git/core.sha1函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript sha1函數的具體用法?TypeScript sha1怎麽用?TypeScript sha1使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了sha1函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: sha1
export default async function *composePackfile(items : AsyncIterableIterator<Entry>, count : number) {
const hash = sha1();
yield hash.update(packHeader(count));
for await(const item of items){
for(const chunk of packFrame(item)){
yield hash.update(chunk);
}
}
yield packHash(hash.digest());
}
示例2: await
export default async function *normalizeEntries(entries : AsyncIterableIterator<Entry>, progress? : Progress) : AsyncIterableIterator<RawObject> {
const references = new Map<string, NormalEntry>();
const offsets = new Map<number, NormalEntry>();
let deltas = 0;
for await(let entry of entries){
if(entry.type === Type.ofsDelta
|| entry.type === Type.refDelta){
const base = getBase(entry);
const body = applyDelta(entry.body, base.body)
deltas++;
entry = {
type: base.type,
body,
offset: entry.offset
};
}
const type = Type[entry.type];
const body = encodeRaw(type, entry.body);
const hash = sha1(body);
references.set(hash, entry);
offsets.set(entry.offset, entry);
yield {
type,
body,
hash
};
}
if(progress) progress(`Resolving deltas: 100% (${deltas}/${deltas}), done.\n`);
function getBase(entry : OfsDeltaEntry | RefDeltaEntry) {
if(entry.type === Type.ofsDelta) {
const base = offsets.get(entry.offset - entry.ref);
if(!base) throw new Error(`Cannot find base of ofs-delta ${entry.offset} - ${entry.ref}`);
return base;
} else {
const base = references.get(entry.ref);
if(!base) throw new Error(`Cannot find base of ref-delta ${entry.offset}: ${entry.ref}`);
//ToDo: thinpack lookup
return base;
}
}
}
示例3: digest
digest(){
const result = this.sha.digest();
this.sha = sha1();
return result;
}
示例4: constructor
constructor(chunks : AsyncIterableIterator<Uint8Array>){
super(chunks);
this.sha = sha1();
this.temp = new Uint8Array(1);
}
示例5: saveObject
async saveObject(object : GitObject) {
const raw = encodeObject(object);
const hash = sha1(raw);
await super.saveRaw(hash, raw);
return hash;
}