lib/utils/sourceMap.js
function insert(outMap, inMap, length, index) {
  // Move existing mappings
  if (length) {
    outMap._mappings.unsortedForEach(mapping => {
      if (mapping.generatedLine > index) mapping.generatedLine += length;
    });
  }

  // Add new mappings
  if (inMap) {
    const inConsumer = new SourceMapConsumer(inMap.toJSON());

    inConsumer.eachMapping(mapping => {
      outMap.addMapping({
        source: mapping.source,
        original: mapping.source == null
          ? null
          : {
              line: mapping.originalLine,
              column: mapping.originalColumn
            },
        generated: {
          line: index + mapping.generatedLine - 1,
          column: mapping.generatedColumn
        }
      });
    });

    inConsumer.sources.forEach((source, idx) => {
      outMap.setSourceContent(source, inConsumer.sourcesContent[idx]);
    });
  }
}
function insert(outMap, inMap, length, index) {
  // Move existing mappings
  if (length) {
    outMap._mappings.unsortedForEach(mapping => {
      if (mapping.generatedLine > index) mapping.generatedLine += length;
    });
  }

  // Add new mappings
  if (inMap) {
    const inConsumer = new SourceMapConsumer(inMap.toJSON());

    inConsumer.eachMapping(mapping => {
      outMap.addMapping({
        source: mapping.source,
        original: mapping.source == null
          ? null
          : {
              line: mapping.originalLine,
              column: mapping.originalColumn
            },
        generated: {
          line: index + mapping.generatedLine - 1,
          column: mapping.generatedColumn
        }
      });
    });

    inConsumer.sources.forEach((source, idx) => {
      outMap.setSourceContent(source, inConsumer.sourcesContent[idx]);
    });
  }
}
function insert ( outMap , inMap , length , index ) { // Move existing mappings if ( length ) { outMap . _mappings . unsortedForEach ( mapping => { if ( mapping . generatedLine > index ) mapping . generatedLine += length ; } ) ; } // Add new mappings if ( inMap ) { const inConsumer = new SourceMapConsumer ( inMap . toJSON ( ) ) ; inConsumer . eachMapping ( mapping => { outMap . addMapping ( { source : mapping . source , original : mapping . source == null ? null : { line : mapping . originalLine , column : mapping . originalColumn } , generated : { line : index + mapping . generatedLine - 1 , column : mapping . generatedColumn } } ) ; } ) ; inConsumer . sources . forEach ( ( source , idx ) => { outMap . setSourceContent ( source , inConsumer . sourcesContent [ idx ] ) ; } ) ; } }
Insert line in 'outMap' with 'inMap' at line 'index'
@param {SourceMapGenerator} outMap
@param {SourceMapGenerator} [inMap]
@param {Number} length
@param {Number} index
Insert line in outMap with inMap at line index