* @param {SourceMap.StringCharIterator} stringCharIterator * @returns {number}
(stringCharIterator)
| 329 | * @returns {number} |
| 330 | */ |
| 331 | function decodeVLQ(stringCharIterator) { |
| 332 | // Read unsigned value. |
| 333 | let result = 0; |
| 334 | let shift = 0; |
| 335 | let digit; |
| 336 | do { |
| 337 | digit = base64Map[stringCharIterator.next()]; |
| 338 | result += (digit & VLQ_BASE_MASK) << shift; |
| 339 | shift += VLQ_BASE_SHIFT; |
| 340 | } while (digit & VLQ_CONTINUATION_MASK); |
| 341 | |
| 342 | // Fix the sign. |
| 343 | const negative = result & 1; |
| 344 | // Use unsigned right shift, so that the 32nd bit is properly shifted to the |
| 345 | // 31st, and the 32nd becomes unset. |
| 346 | result >>>= 1; |
| 347 | if (!negative) { |
| 348 | return result; |
| 349 | } |
| 350 | |
| 351 | // We need to OR here to ensure the 32nd bit (the sign bit in an Int32) is |
| 352 | // always set for negative numbers. If `result` were 1, (meaning `negate` is |
| 353 | // true and all other bits were zeros), `result` would now be 0. But -0 |
| 354 | // doesn't flip the 32nd bit as intended. All other numbers will successfully |
| 355 | // set the 32nd bit without issue, so doing this is a noop for them. |
| 356 | return -result | (1 << 31); |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * @param {SourceMapV3} payload |