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