sourceMap.findEntry(lineOffset, columnOffset)


  • lineOffset <number> 生成源中的零索引行号偏移
  • columnOffset <number> 生成源中的零索引列号偏移
  • 返回:<Object>

给定生成源文件中的行偏移和列偏移,如果找到,则返回表示原始文件中 SourceMap 范围的对象;如果未找到,则返回空对象。

【Given a line offset and column offset in the generated source file, returns an object representing the SourceMap range in the original file if found, or an empty object if not.】

返回的对象包含以下键:

【The object returned contains the following keys:】

  • generatedLine <number> 生成源中范围起始行的行偏移
  • generatedColumn <number> 在生成源中范围开始的列偏移量
  • originalSource <string> 原始来源的文件名,如 SourceMap 中所示
  • originalLine <number> 原始源中范围起始行的行偏移
  • originalColumn <number> 原始源中范围起始的列偏移
  • name <string>

返回值表示在 SourceMap 中出现的原始范围,基于零索引偏移,而不是在错误信息和 CallSite 对象中显示的从 1 开始的行号和列号。

【The returned value represents the raw range as it appears in the SourceMap, based on zero-indexed offsets, not 1-indexed line and column numbers as they appear in Error messages and CallSite objects.】

要从 Error 堆栈和 CallSite 对象报告的 lineNumber 和 columnNumber 获取对应的从 1 开始的行号和列号,请使用 sourceMap.findOrigin(lineNumber, columnNumber)

【To get the corresponding 1-indexed line and column numbers from a lineNumber and columnNumber as they are reported by Error stacks and CallSite objects, use sourceMap.findOrigin(lineNumber, columnNumber)