Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 58x 58x 1x 1x 1x 57x 4x 4x 4x 53x 53x 53x 58x 1x 1x 233x 233x 1x 1x 1x 1x 1x 1175x 16x 16x 1175x 1175x 1175x 1x 1x 1x 896x 896x 1x 1x 1x 1x 1x 1x 1x 419x 419x 1x 1x 1x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 143x 143x 142x 142x 143x 143x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 2x 2x 2x 1x 1x 17x 17x 17x 17x 1x 1x 1x 1x 1x | // @ts-check // SPDX-License-Identifier: Zlib // SPDX-FileCopyrightText: 2016 Sylvain Fargier // SPDX-Created: 2016-11-08T14:04:02+01:00 // SPDX-FileContributor: Author: Sylvain Fargier <fargie_s> <fargier.sylvain@gmail.com> "use strict"; class VarBuffer { /** * @param {?(Buffer|number)=} buf */ constructor(buf) { this.length = 0; if (Number.isInteger(buf)) { /* @ts-ignore: checked above */ this._buffer = Buffer.allocUnsafe(buf); } else if (buf instanceof Buffer) { this._buffer = buf; this.length = buf.length; } else { this._buffer = Buffer.allocUnsafe(VarBuffer.BUF_SZ); } } reset() { this.length = 0; } /** * @param {Buffer} data */ add(data) { while (data.length > this._buffer.length - this.length) { this._enlarge(); } data.copy(this._buffer, this.length, 0); this.length += data.length; } /** @return {Buffer} */ buffer() { return this._buffer.slice(0, this.length); } /** * @param {number} start * @param {number} [end] * @return {Buffer} */ slice(start, end) { return this._buffer.slice(start, end ?? this.length); } /** @return {number} */ reserved() { return this._buffer.length; } /** @param {number} size */ resize(size) { while (size > this._buffer.length) { this._enlarge(); } this.length = size; } /** * @brief remove the first elements of the buffer * @param {number} [n=1] */ shift(n = 1) { if (this.length === 0 || !Number.isInteger(n) || n < 1) { return; } if (n > this.length) { n = this.length; } const remainder = this.slice(n); this.reset(); if (remainder.length > 0) { this.add(remainder); } } /** * @brief copy part of a buffer at a specific offset * @param {Buffer|VarBuffer} target destination buffer * @param {number} targetStart target start offset * @param {number} sourceStart source (this) start offset * @param {number} [sourceEnd] source end offset * @return {number} number of bytes copied */ copy(target, targetStart, sourceStart, sourceEnd) { if (target instanceof VarBuffer) { target = target._buffer; } return this._buffer.copy(target, targetStart, sourceStart, (sourceEnd ?? this.length)); } _enlarge() { var old = this._buffer; this._buffer = Buffer.allocUnsafe(this._buffer.length * 2); old.copy(this._buffer, 0, 0, this.length); } } VarBuffer.BUF_SZ = 2048; export default VarBuffer; |