class SourceMap::Map
def build_vlq_string
def build_vlq_string source_id = 0 source_line = 1 source_column = 0 name_id = 0 by_lines = @mappings.group_by { |m| m.generated.line } sources_index = Hash[sources.each_with_index.to_a] names_index = Hash[names.each_with_index.to_a] ary = (1..(by_lines.keys.max || 1)).map do |line| generated_column = 0 (by_lines[line] || []).map do |mapping| group = [] group << mapping.generated.column - generated_column group << sources_index[mapping.source] - source_id group << mapping.original.line - source_line group << mapping.original.column - source_column group << names_index[mapping.name] - name_id if mapping.name generated_column = mapping.generated.column source_id = sources_index[mapping.source] source_line = mapping.original.line source_column = mapping.original.column name_id = names_index[mapping.name] if mapping.name group end end VLQ.encode_mappings(ary) end