本文整理汇总了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());
}
开发者ID:strangesast,项目名称:es-git,代码行数:13,代码来源:compose-packfile.ts
示例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;
}
}
}
开发者ID:strangesast,项目名称:es-git,代码行数:46,代码来源:normalize-entries.ts
示例3: digest
digest(){
const result = this.sha.digest();
this.sha = sha1();
return result;
}
开发者ID:strangesast,项目名称:es-git,代码行数:5,代码来源:DigestableAsyncBuffer.ts
示例4: constructor
constructor(chunks : AsyncIterableIterator<Uint8Array>){
super(chunks);
this.sha = sha1();
this.temp = new Uint8Array(1);
}
开发者ID:strangesast,项目名称:es-git,代码行数:5,代码来源:DigestableAsyncBuffer.ts
示例5: saveObject
async saveObject(object : GitObject) {
const raw = encodeObject(object);
const hash = sha1(raw);
await super.saveRaw(hash, raw);
return hash;
}
开发者ID:strangesast,项目名称:es-git,代码行数:6,代码来源:index.ts
注:本文中的@es-git/core.sha1函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论