本文整理汇总了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;
}