prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
80 lines (68 loc) • 2.67 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PerFileBreakpointMap = undefined;
var _Breakpoint = require("./Breakpoint.js");
// Storage for all the breakpoints in one source file
// Each source file will be associated with one PerFileBreakpointMap
class PerFileBreakpointMap {
constructor(filePath) {
this._filePath = filePath;
this._breakpoints = new Map();
}
//map of line:column to Breakpoint objects
addBreakpoint(line, column = 0, temporary, enabled) {
let breakpoint = new _Breakpoint.Breakpoint(this._filePath, line, column, temporary, enabled);
let key = this._getKey(line, column);
this._breakpoints.set(key, breakpoint);
}
getBreakpoint(line, column = 0) {
//check for a column breakpoint first, then line breakpoint
if (column !== 0) {
let key = this._getKey(line, column);
if (this._breakpoints.has(key)) {
return this._breakpoints.get(key);
} else {
key = this._getKey(line, 0);
if (this._breakpoints.has(key)) {
return this._breakpoints.get(key);
}
}
} else {
let key = this._getKey(line, 0);
if (this._breakpoints.has(key)) {
return this._breakpoints.get(key);
}
}
return undefined;
}
removeBreakpoint(line, column = 0) {
let key = this._getKey(line, column);
if (this._breakpoints.has(key)) {
this._breakpoints.delete(key);
}
}
enableBreakpoint(line, column = 0) {
let key = this._getKey(line, column);
let breakpoint = this._breakpoints.get(key);
if (breakpoint) breakpoint.enabled = true;
}
disableBreakpoint(line, column = 0) {
let key = this._getKey(line, column);
let breakpoint = this._breakpoints.get(key);
if (breakpoint) breakpoint.enabled = false;
}
_getKey(line, column) {
return `${line}:${column}`;
}
}
exports.PerFileBreakpointMap = PerFileBreakpointMap; /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
//# sourceMappingURL=PerFileBreakpointMap.js.map