in src/lib.ts [158:186]
constructor(contents: string, private rawSourceMap?: RawSourceMap) {
const regex = /\r\n|\r|\n/g;
let index = 0;
let match: RegExpExecArray | null;
this.lines = [];
while (match = regex.exec(contents)) {
this.lines.push({ content: contents.substring(index, match.index), ending: match[0], mappings: null });
index = regex.lastIndex;
}
if (contents.length > 0) {
this.lines.push({ content: contents.substring(index, contents.length), ending: '', mappings: null });
}
if (rawSourceMap) {
const sourceMapConsumer = new SourceMapConsumer(rawSourceMap);
sourceMapConsumer.eachMapping((mapping) => {
// Note that the generatedLine index is one based;
let line = this.lines[mapping.generatedLine - 1];
if (line) {
if (!line.mappings) {
line.mappings = [];
}
line.mappings.push(mapping);
}
}, null, SourceMapConsumer.GENERATED_ORDER);
}
}