class SourceMap::Map
def self.decode_vlq_mappings(str, sources = [], names = [])
names - Array of Strings from 'names' attribute
sources - Array of Strings from 'sources' attribute
str - VLQ string from 'mappings' attribute
Internal: Decode VLQ mappings and match up sources and symbol names.
def self.decode_vlq_mappings(str, sources = [], names = []) mappings = [] source_id = 0 original_line = 1 original_column = 0 name_id = 0 VLQ.decode_mappings(str).each_with_index do |group, index| generated_column = 0 generated_line = index + 1 group.each do |segment| generated_column += segment[0] generated = Offset.new(generated_line, generated_column) if segment.size >= 4 source_id += segment[1] original_line += segment[2] original_column += segment[3] source = sources[source_id] original = Offset.new(original_line, original_column) else # TODO: Research this case next end if segment[4] name_id += segment[4] name = names[name_id] end mappings << Mapping.new(source, generated, original, name) end end mappings end