當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.sha1函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。