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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | 41x 41x 41x 41x 41x 41x 41x 41x 11962x 41x 41x 41x 11962x 11921x 11921x 11921x 11921x 11962x 11962x 11962x 41x 41x 3889x 3889x 41x 41x 107382x 243x 107382x 8940x 8940x 107382x 107382x 41x 41x 913x 913x 913x 913x 913x 41x 41x 41x 41x 41x 41x 41x 41x 105750x 105750x 99757x 99757x 105750x 41x 41x 8940x 8940x 8940x 8699x 8940x 241x 241x 241x 241x 8940x 8940x 8940x 41x 41x 48498x 48498x 48498x 48498x 41x 41x 105x 105x 105x 41x 41x 5125x 5125x 5125x 5125x 5125x 5125x 5125x 5125x 41x 41x 1855x 1855x 1855x 1855x 41x 41x 38272x 38272x 38272x 38272x 41x 41x 4166x 4166x 4166x 41x 41x 754x 754x 754x 754x 41x 41x 763x 763x 763x 763x 41x 41x 828x 828x 828x 828x 41x 41x 10007x 10007x 10007x 10007x 10007x 10007x 10007x 10007x 10007x 41x 41x 10007x 10007x 84985x 84985x 84985x 10007x 41x 41x 154982x 1x 1x 154981x 154981x 154981x 154982x 41x 41x 41x 41x 432x 432x 432x 432x 432x 41x 41x 14x 14x 14x 14x 14x 14x 14x 41x 41x 2020x 2020x 2020x 2020x 2020x 41x 41x 49945x 49945x 49945x 49945x 49945x 41x 41x 637x 637x 637x 637x 637x 41x 41x 650x 650x 650x 650x 650x 41x 41x 684x 684x 684x 684x 684x 41x 41x 10652x 10652x 10652x 10652x 10652x 92278x 92278x 10652x 10652x 10652x 41x 41x 80008x 80008x 41x 41x 64252x 64252x 64252x 64252x 41x 41x 22150x 22150x 41x 41x 230769x 230769x 41x 41x 66564x 66564x 41x | // Copyright (c) ZeroC, Inc. const bufferOverflowExceptionMsg = "BufferOverflowException"; const bufferUnderflowExceptionMsg = "BufferUnderflowException"; const indexOutOfBoundsExceptionMsg = "IndexOutOfBoundsException"; export class Buffer { constructor(buffer) { if (buffer !== undefined) { this.b = buffer; this.v = new DataView(this.b); this._limit = this.b.byteLength; } else { this.b = null; // ArrayBuffer this.v = null; // DataView this._limit = 0; } this._position = 0; this._shrinkCounter = 0; } empty() { return this._limit === 0; } resize(n) { if (n === 0) { this.clear(); } else if (n > this.capacity) { this.reserve(n); } this._limit = n; } clear() { this.b = null; this.v = null; this._position = 0; this._limit = 0; } // // Call expand(n) to add room for n additional bytes. Note that expand() // examines the current position of the buffer first; we don't want to // expand the buffer if the caller is writing to a location that is // already in the buffer. // expand(n) { const sz = this.capacity === 0 ? n : this._position + n; if (sz > this._limit) { this.resize(sz); } } reserve(n) { if (n > this.capacity) { const capacity = Math.max(1024, Math.max(n, 2 * this.capacity)); if (!this.b) { this.b = new ArrayBuffer(capacity); } else { const b = new Uint8Array(capacity); b.set(new Uint8Array(this.b)); this.b = b.buffer; } this.v = new DataView(this.b); } else if (n < this.capacity) { this.b = this.b.slice(0, n); this.v = new DataView(this.b); } } put(v) { if (this._position === this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setUint8(this._position, v); this._position++; } putAt(i, v) { if (i >= this._limit) { throw new RangeError(indexOutOfBoundsExceptionMsg); } this.v.setUint8(i, v); } putArray(v) { // Expects an Uint8Array if (!(v instanceof Uint8Array)) { throw new TypeError("argument is not a Uint8Array"); } if (v.byteLength > 0) { if (this._position + v.length > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } new Uint8Array(this.b, 0, this.b.byteLength).set(v, this._position); this._position += v.byteLength; } } putShort(v) { if (this._position + 2 > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setInt16(this._position, v, true); this._position += 2; } putInt(v) { if (this._position + 4 > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setInt32(this._position, v, true); this._position += 4; } putIntAt(i, v) { if (i + 4 > this._limit || i < 0) { throw new RangeError(indexOutOfBoundsExceptionMsg); } this.v.setInt32(i, v, true); } putFloat(v) { if (this._position + 4 > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setFloat32(this._position, v, true); this._position += 4; } putDouble(v) { if (this._position + 8 > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setFloat64(this._position, v, true); this._position += 8; } putLong(v) { if (this._position + 8 > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } this.v.setBigInt64(this._position, v, true); this._position += 8; } writeString(stream, v) { // // Encode the string as utf8 // const encoded = unescape(encodeURIComponent(v)); stream.writeSize(encoded.length); stream.expand(encoded.length); this.putString(encoded, encoded.length); } putString(v, sz) { if (this._position + sz > this._limit) { throw new RangeError(bufferOverflowExceptionMsg); } for (let i = 0; i < sz; ++i) { this.v.setUint8(this._position, v.charCodeAt(i)); this._position++; } } get() { if (this._position >= this._limit) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getUint8(this._position); this._position++; return v; } getAt(i) { if (i < 0 || i >= this._limit) { throw new RangeError(indexOutOfBoundsExceptionMsg); } return this.v.getUint8(i); } getArray(length) { if (this._position + length > this._limit) { throw new RangeError(bufferUnderflowExceptionMsg); } const buffer = this.b.slice(this._position, this._position + length); this._position += length; return new Uint8Array(buffer); } getArrayAt(position, length) { if (position + length > this._limit) { throw new RangeError(bufferUnderflowExceptionMsg); } if (length === undefined) { return new Uint8Array(this.b.slice(position)); } else { return new Uint8Array(this.b.slice(position, position + length)); } } getShort() { if (this._limit - this._position < 2) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getInt16(this._position, true); this._position += 2; return v; } getInt() { if (this._limit - this._position < 4) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getInt32(this._position, true); this._position += 4; return v; } getFloat() { if (this._limit - this._position < 4) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getFloat32(this._position, true); this._position += 4; return v; } getDouble() { if (this._limit - this._position < 8) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getFloat64(this._position, true); this._position += 8; return v; } getLong() { if (this._limit - this._position < 8) { throw new RangeError(bufferUnderflowExceptionMsg); } const v = this.v.getBigInt64(this._position, true); this._position += 8; return v; } getString(length) { if (this._position + length > this._limit) { throw new RangeError(bufferUnderflowExceptionMsg); } const data = new DataView(this.b, this._position, length); let s = ""; for (let i = 0; i < length; ++i) { s += String.fromCharCode(data.getUint8(i)); } this._position += length; return decodeURIComponent(escape(s)); } get position() { return this._position; } set position(value) { if (value >= 0 && value <= this._limit) { this._position = value; } } get limit() { return this._limit; } get capacity() { return this.b === null ? 0 : this.b.byteLength; } get remaining() { return this._limit - this._position; } } |