Add a deep copy method for SourceMap (#61)

This commit is contained in:
Tien 2017-06-20 10:45:23 -07:00 коммит произвёл Christian Gonzalez
Родитель 384c124c54
Коммит 284e424ba0
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace SourcemapToolkit.SourcemapParser
{
@ -35,6 +36,19 @@ namespace SourcemapToolkit.SourcemapParser
/// </summary>
public List<MappingEntry> ParsedMappings;
public SourceMap Clone()
{
return new SourceMap
{
Version = this.Version,
File = this.File,
Mappings = this.Mappings,
Sources = new List<string>(this.Sources),
Names = new List<string>(this.Names),
ParsedMappings = new List<MappingEntry>(this.ParsedMappings.Select(m => m.Clone()))
};
}
/// <summary>
/// Applies the mappings of a sub source map to the current source map
/// Each mapping to the supplied source file is rewritten using the supplied source map