@@ -198,23 +198,67 @@ Creates a new `sourceMap` instance. |
198 | 198 |
|
199 | 199 | Getter for the payload used to construct the [`SourceMap`][] instance. |
200 | 200 |
|
201 | | -#### `sourceMap.findEntry(lineNumber, columnNumber)` |
| 201 | +#### `sourceMap.findEntry(lineOffset, columnOffset)` |
202 | 202 |
|
203 | | -* `lineNumber` {number} |
204 | | -* `columnNumber` {number} |
| 203 | +* `lineOffset` {number} The zero-indexed line number offset in |
| 204 | + the generated source |
| 205 | +* `columnOffset` {number} The zero-indexed column number offset |
| 206 | + in the generated source |
205 | 207 | * Returns: {Object} |
206 | 208 |
|
207 | | -Given a line number and column number in the generated source file, returns |
208 | | -an object representing the position in the original file. The object returned |
209 | | -consists of the following keys: |
210 | | -
|
211 | | -* generatedLine: {number} |
212 | | -* generatedColumn: {number} |
213 | | -* originalSource: {string} |
214 | | -* originalLine: {number} |
215 | | -* originalColumn: {number} |
| 209 | +Given a line offset and column offset in the generated source |
| 210 | +file, returns an object representing the SourceMap range in the |
| 211 | +original file if found, or an empty object if not. |
| 212 | +
|
| 213 | +The object returned contains the following keys: |
| 214 | +
|
| 215 | +* generatedLine: {number} The line offset of the start of the |
| 216 | + range in the generated source |
| 217 | +* generatedColumn: {number} The column offset of start of the |
| 218 | + range in the generated source |
| 219 | +* originalSource: {string} The file name of the original source, |
| 220 | + as reported in the SourceMap |
| 221 | +* originalLine: {number} The line offset of the start of the |
| 222 | + range in the original source |
| 223 | +* originalColumn: {number} The column offset of start of the |
| 224 | + range in the original source |
216 | 225 | * name: {string} |
217 | 226 |
|
| 227 | +The returned value represents the raw range as it appears in the |
| 228 | +SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and |
| 229 | +column numbers as they appear in Error messages and CallSite |
| 230 | +objects. |
| 231 | +
|
| 232 | +To get the corresponding 1-indexed line and column numbers from a |
| 233 | +lineNumber and columnNumber as they are reported by Error stacks |
| 234 | +and CallSite objects, use `sourceMap.findOrigin(lineNumber, |
| 235 | +columnNumber)` |
| 236 | +
|
| 237 | +#### `sourceMap.findOrigin(lineNumber, columnNumber)` |
| 238 | +
|
| 239 | +* `lineNumber` {number} The 1-indexed line number of the call |
| 240 | + site in the generated source |
| 241 | +* `columnOffset` {number} The 1-indexed column number |
| 242 | + of the call site in the generated source |
| 243 | +* Returns: {Object} |
| 244 | +
|
| 245 | +Given a 1-indexed lineNumber and columnNumber from a call site in |
| 246 | +the generated source, find the corresponding call site location |
| 247 | +in the original source. |
| 248 | +
|
| 249 | +If the lineNumber and columnNumber provided are not found in any |
| 250 | +source map, then an empty object is returned. Otherwise, the |
| 251 | +returned object contains the following keys: |
| 252 | +
|
| 253 | +* name: {string | undefined} The name of the range in the |
| 254 | + source map, if one was provided |
| 255 | +* fileName: {string} The file name of the original source, as |
| 256 | + reported in the SourceMap |
| 257 | +* lineNumber: {number} The 1-indexed lineNumber of the |
| 258 | + corresponding call site in the original source |
| 259 | +* columnNumber: {number} The 1-indexed columnNumber of the |
| 260 | + corresponding call site in the original source |
| 261 | +
|
218 | 262 | [CommonJS]: modules.md |
219 | 263 | [ES Modules]: esm.md |
220 | 264 | [Source map v3 format]: https://sourcemaps.info/spec.html#h.mofvlxcwqzej |
|