Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! module: add SourceMap.lineLengths
Document lineLengths argument
Make lineLengths part of an option bag rather than a positional arg
  • Loading branch information
isaacs committed Jul 11, 2023
commit fed5a2fee4bcac96d362950d1fdf9733e50abfd8
4 changes: 2 additions & 2 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ added:
- v12.17.0
-->

#### `new SourceMap(payload)`
#### `new SourceMap(payload[, { lineLengths }])`

* `payload` {Object}
* `lineLengths` {number\[]}
Expand All @@ -288,7 +288,7 @@ Creates a new `sourceMap` instance.
* `mappings`: {string}
* `sourceRoot`: {string}

`lineLengths` is an array of the length of each line in the
`lineLengths` is an optional array of the length of each line in the
generated code.

#### `sourceMap.payload`
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/source_map/source_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SourceMap {
* @constructor
* @param {SourceMapV3} payload
*/
constructor(payload, lineLengths) {
constructor(payload, { lineLengths } = { __proto__: null }) {
if (!base64Map) {
const base64Digits =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/source_map/source_map_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function findSourceMap(sourceURL) {
}
let sourceMap = entry.sourceMap;
if (sourceMap === undefined) {
sourceMap = new SourceMap(entry.data, entry.lineLengths);
sourceMap = new SourceMap(entry.data, { lineLengths: entry.lineLengths });
entry.sourceMap = sourceMap;
}
return sourceMap;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-source-map-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const { readFileSync } = require('fs');
const lineLengths = readFileSync(
require.resolve('../fixtures/source-map/disk.map'), 'utf8'
).replace(/\n$/, '').split('\n').map((l) => l.length);
const sourceMap = new SourceMap(payload, lineLengths);
const sourceMap = new SourceMap(payload, { lineLengths });
const {
originalLine,
originalColumn,
Expand Down