decodeVLQ decodes a base64 VLQ-encoded segment into its integer fields.
(seg string)
| 38 | |
| 39 | // decodeVLQ decodes a base64 VLQ-encoded segment into its integer fields. |
| 40 | func decodeVLQ(seg string) []int { |
| 41 | var out []int |
| 42 | shift, value := 0, 0 |
| 43 | for i := 0; i < len(seg); i++ { |
| 44 | digit := b64lookup[seg[i]] |
| 45 | if digit < 0 { |
| 46 | return out |
| 47 | } |
| 48 | d := int(digit) |
| 49 | cont := d&32 != 0 |
| 50 | d &= 31 |
| 51 | value += d << shift |
| 52 | shift += 5 |
| 53 | if !cont { |
| 54 | neg := value&1 != 0 |
| 55 | value >>= 1 |
| 56 | if neg { |
| 57 | value = -value |
| 58 | } |
| 59 | out = append(out, value) |
| 60 | shift, value = 0, 0 |
| 61 | } |
| 62 | } |
| 63 | return out |
| 64 | } |
| 65 | |
| 66 | // extractSourceMap finds and parses the source map referenced by a transformed |
| 67 | // source file. fileURL is the URL the text was fetched from (used to resolve a |