UNPKG

low-level

Version:
35 lines 1.04 kB
export 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)); } } export 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; } } //# sourceMappingURL=utils.js.map