low-level
Version:
40 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractIterator = exports.UintUtils = void 0;
class UintUtils {
static fixBufferByteLength(buffer, correctByteLength) {
if (buffer.byteLength === correctByteLength) {
return buffer;
}
const newBuffer = Buffer.alloc(correctByteLength);
newBuffer.set(buffer, correctByteLength - buffer.byteLength);
return newBuffer;
}
static fixUintByteLength(CLS, uint, correctByteLength) {
return new CLS(this.fixBufferByteLength(uint.getRaw(), correctByteLength));
}
}
exports.UintUtils = UintUtils;
class AbstractIterator {
entries;
constructor(entries) {
this.entries = entries;
}
[Symbol.iterator]() { return this; }
next() {
const result = this.entries.next();
if (result.done) {
return { done: true, value: undefined };
}
return { done: false, value: this._next(result.value) };
}
all() {
const result = [];
for (const value of this) {
result.push(value);
}
return result;
}
}
exports.AbstractIterator = AbstractIterator;
//# sourceMappingURL=utils.js.map