@es-git/core
Advanced tools
Comparing version 0.4.0 to 0.4.2
@@ -17,4 +17,6 @@ export default class AsyncBuffer { | ||
rest(length: number): AsyncIterableIterator<Uint8Array>; | ||
chunk(): Promise<Uint8Array>; | ||
rewind(length: number): void; | ||
isDone(): Promise<boolean>; | ||
complete(): Promise<void>; | ||
} |
@@ -87,3 +87,3 @@ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
if (chunkSize == 0) { | ||
yield __await(this.peek(1)); | ||
yield __await(this.nextData(1)); | ||
} | ||
@@ -116,2 +116,13 @@ else { | ||
} | ||
async chunk() { | ||
if (this.pointer === this.data.length) { | ||
await this.nextData(1); | ||
} | ||
const pointer = this.pointer; | ||
this.pointer = this.data.length; | ||
return this.data.subarray(pointer); | ||
} | ||
rewind(length) { | ||
this.pointer -= length; | ||
} | ||
async isDone() { | ||
@@ -118,0 +129,0 @@ return this.nextData(1).then(x => false, x => true); |
@@ -339,3 +339,3 @@ "use strict"; | ||
_context6.next = 6; | ||
return __await(this.peek(1)); | ||
return __await(this.nextData(1)); | ||
@@ -459,3 +459,3 @@ case 6: | ||
}, { | ||
key: "isDone", | ||
key: "chunk", | ||
value: function () { | ||
@@ -465,2 +465,3 @@ (0, _newArrowCheck3.default)(undefined, undefined); | ||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() { | ||
var pointer; | ||
return _regenerator2.default.wrap(function _callee6$(_context7) { | ||
@@ -470,3 +471,46 @@ while (1) { | ||
case 0: | ||
return _context7.abrupt("return", this.nextData(1).then(function (x) { | ||
if (!(this.pointer === this.data.length)) { | ||
_context7.next = 3; | ||
break; | ||
} | ||
_context7.next = 3; | ||
return this.nextData(1); | ||
case 3: | ||
pointer = this.pointer; | ||
this.pointer = this.data.length; | ||
return _context7.abrupt("return", this.data.subarray(pointer)); | ||
case 6: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee6, this); | ||
})); | ||
function chunk() { | ||
return _ref7.apply(this, arguments); | ||
} | ||
return chunk; | ||
}.bind(undefined)() | ||
}, { | ||
key: "rewind", | ||
value: function rewind(length) { | ||
this.pointer -= length; | ||
} | ||
}, { | ||
key: "isDone", | ||
value: function () { | ||
(0, _newArrowCheck3.default)(undefined, undefined); | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7() { | ||
return _regenerator2.default.wrap(function _callee7$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
return _context8.abrupt("return", this.nextData(1).then(function (x) { | ||
return false; | ||
@@ -479,10 +523,10 @@ }, function (x) { | ||
case "end": | ||
return _context7.stop(); | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee6, this); | ||
}, _callee7, this); | ||
})); | ||
function isDone() { | ||
return _ref7.apply(this, arguments); | ||
return _ref8.apply(this, arguments); | ||
} | ||
@@ -497,60 +541,60 @@ | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7() { | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8() { | ||
var _a, _b, rest, e_2, _c; | ||
return _regenerator2.default.wrap(function _callee7$(_context8) { | ||
return _regenerator2.default.wrap(function _callee8$(_context9) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
_context8.prev = 0; | ||
_context9.prev = 0; | ||
_a = __asyncValues(this.rest()); | ||
case 2: | ||
_context8.next = 4; | ||
_context9.next = 4; | ||
return _a.next(); | ||
case 4: | ||
_b = _context8.sent; | ||
_b = _context9.sent; | ||
if (_b.done) { | ||
_context8.next = 11; | ||
_context9.next = 11; | ||
break; | ||
} | ||
_context8.next = 8; | ||
_context9.next = 8; | ||
return _b.value; | ||
case 8: | ||
rest = _context8.sent; | ||
rest = _context9.sent; | ||
case 9: | ||
_context8.next = 2; | ||
_context9.next = 2; | ||
break; | ||
case 11: | ||
_context8.next = 16; | ||
_context9.next = 16; | ||
break; | ||
case 13: | ||
_context8.prev = 13; | ||
_context8.t0 = _context8["catch"](0); | ||
e_2 = { error: _context8.t0 }; | ||
_context9.prev = 13; | ||
_context9.t0 = _context9["catch"](0); | ||
e_2 = { error: _context9.t0 }; | ||
case 16: | ||
_context8.prev = 16; | ||
_context8.prev = 17; | ||
_context9.prev = 16; | ||
_context9.prev = 17; | ||
if (!(_b && !_b.done && (_c = _a.return))) { | ||
_context8.next = 21; | ||
_context9.next = 21; | ||
break; | ||
} | ||
_context8.next = 21; | ||
_context9.next = 21; | ||
return _c.call(_a); | ||
case 21: | ||
_context8.prev = 21; | ||
_context9.prev = 21; | ||
if (!e_2) { | ||
_context8.next = 24; | ||
_context9.next = 24; | ||
break; | ||
@@ -562,17 +606,17 @@ } | ||
case 24: | ||
return _context8.finish(21); | ||
return _context9.finish(21); | ||
case 25: | ||
return _context8.finish(16); | ||
return _context9.finish(16); | ||
case 26: | ||
case "end": | ||
return _context8.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee7, this, [[0, 13, 16, 26], [17,, 21, 25]]); | ||
}, _callee8, this, [[0, 13, 16, 26], [17,, 21, 25]]); | ||
})); | ||
function complete() { | ||
return _ref8.apply(this, arguments); | ||
return _ref9.apply(this, arguments); | ||
} | ||
@@ -579,0 +623,0 @@ |
{ | ||
"name": "@es-git/core", | ||
"version": "0.4.0", | ||
"version": "0.4.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
@@ -82,3 +82,3 @@ import { concat } from './utils'; | ||
if(chunkSize == 0){ | ||
await this.peek(1); | ||
await this.nextData(1); | ||
}else{ | ||
@@ -98,2 +98,15 @@ yield await this.next(chunkSize); | ||
async chunk(){ | ||
if(this.pointer === this.data.length){ | ||
await this.nextData(1); | ||
} | ||
const pointer = this.pointer; | ||
this.pointer = this.data.length; | ||
return this.data.subarray(pointer); | ||
} | ||
rewind(length : number){ | ||
this.pointer -= length; | ||
} | ||
async isDone(){ | ||
@@ -100,0 +113,0 @@ return this.nextData(1).then(x => false, x => true); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
137419
1642