本文整理匯總了TypeScript中@es-git/core.AsyncBuffer類的典型用法代碼示例。如果您正苦於以下問題:TypeScript AsyncBuffer類的具體用法?TypeScript AsyncBuffer怎麽用?TypeScript AsyncBuffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AsyncBuffer類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: unpktLine
async function unpktLine(line : AsyncBuffer) : Promise<AsyncIterableIterator<Uint8Array> | undefined> {
const size = fromHex(await line.next(4));
if(size === 0) {
return undefined;
}
return line.rest(size - 4);
}
示例2: varLen
async function varLen(buffer : AsyncBuffer){
let byte = await buffer.next();
let ref = byte & 0x7f;
while (byte & 0x80) {
byte = await buffer.next();
ref = ((ref + 1) << 7) | (byte & 0x7f);
}
return ref;
}
示例3: parsePackResponse
export default async function* parsePackResponse(response : AsyncIterableIterator<Uint8Array>) : AsyncIterableIterator<Token> {
const buffer = new AsyncBuffer(response);
while(true){
const line = await unpktLine(buffer);
if(line){
yield await parseLine(new AsyncBuffer(line));
}else{
if(await buffer.isDone()){
break;
}
}
}
}
示例4: async
return async (line : AsyncBuffer) => {
const char = await line.peek();
const action = tree[char];
if(!action){
throw new Error(`unknown key >${String.fromCharCode(char)}< (${char})`);
}
return action(line);
};