summaryrefslogtreecommitdiff
path: root/node_modules/source-map/lib/mapping-list.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/source-map/lib/mapping-list.js')
-rw-r--r--node_modules/source-map/lib/mapping-list.js99
1 files changed, 50 insertions, 49 deletions
diff --git a/node_modules/source-map/lib/mapping-list.js b/node_modules/source-map/lib/mapping-list.js
index 06d1274a..70568610 100644
--- a/node_modules/source-map/lib/mapping-list.js
+++ b/node_modules/source-map/lib/mapping-list.js
@@ -5,7 +5,7 @@
* http://opensource.org/licenses/BSD-3-Clause
*/
-var util = require('./util');
+const util = require("./util");
/**
* Determine whether mappingB is after mappingA with respect to generated
@@ -13,67 +13,68 @@ var util = require('./util');
*/
function generatedPositionAfter(mappingA, mappingB) {
// Optimized for most common case
- var lineA = mappingA.generatedLine;
- var lineB = mappingB.generatedLine;
- var columnA = mappingA.generatedColumn;
- var columnB = mappingB.generatedColumn;
+ const lineA = mappingA.generatedLine;
+ const lineB = mappingB.generatedLine;
+ const columnA = mappingA.generatedColumn;
+ const columnB = mappingB.generatedColumn;
return lineB > lineA || lineB == lineA && columnB >= columnA ||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
}
/**
* A data structure to provide a sorted view of accumulated mappings in a
- * performance conscious manner. It trades a neglibable overhead in general
+ * performance conscious manner. It trades a negligible overhead in general
* case for a large speedup in case of mappings being added in order.
*/
-function MappingList() {
- this._array = [];
- this._sorted = true;
- // Serves as infimum
- this._last = {generatedLine: -1, generatedColumn: 0};
-}
+class MappingList {
+ constructor() {
+ this._array = [];
+ this._sorted = true;
+ // Serves as infimum
+ this._last = {generatedLine: -1, generatedColumn: 0};
+ }
-/**
- * Iterate through internal items. This method takes the same arguments that
- * `Array.prototype.forEach` takes.
- *
- * NOTE: The order of the mappings is NOT guaranteed.
- */
-MappingList.prototype.unsortedForEach =
- function MappingList_forEach(aCallback, aThisArg) {
+ /**
+ * Iterate through internal items. This method takes the same arguments that
+ * `Array.prototype.forEach` takes.
+ *
+ * NOTE: The order of the mappings is NOT guaranteed.
+ */
+ unsortedForEach(aCallback, aThisArg) {
this._array.forEach(aCallback, aThisArg);
- };
+ }
-/**
- * Add the given source mapping.
- *
- * @param Object aMapping
- */
-MappingList.prototype.add = function MappingList_add(aMapping) {
- if (generatedPositionAfter(this._last, aMapping)) {
- this._last = aMapping;
- this._array.push(aMapping);
- } else {
- this._sorted = false;
- this._array.push(aMapping);
+ /**
+ * Add the given source mapping.
+ *
+ * @param Object aMapping
+ */
+ add(aMapping) {
+ if (generatedPositionAfter(this._last, aMapping)) {
+ this._last = aMapping;
+ this._array.push(aMapping);
+ } else {
+ this._sorted = false;
+ this._array.push(aMapping);
+ }
}
-};
-/**
- * Returns the flat, sorted array of mappings. The mappings are sorted by
- * generated position.
- *
- * WARNING: This method returns internal data without copying, for
- * performance. The return value must NOT be mutated, and should be treated as
- * an immutable borrow. If you want to take ownership, you must make your own
- * copy.
- */
-MappingList.prototype.toArray = function MappingList_toArray() {
- if (!this._sorted) {
- this._array.sort(util.compareByGeneratedPositionsInflated);
- this._sorted = true;
+ /**
+ * Returns the flat, sorted array of mappings. The mappings are sorted by
+ * generated position.
+ *
+ * WARNING: This method returns internal data without copying, for
+ * performance. The return value must NOT be mutated, and should be treated as
+ * an immutable borrow. If you want to take ownership, you must make your own
+ * copy.
+ */
+ toArray() {
+ if (!this._sorted) {
+ this._array.sort(util.compareByGeneratedPositionsInflated);
+ this._sorted = true;
+ }
+ return this._array;
}
- return this._array;
-};
+}
exports.MappingList = MappingList;