UNPKG

prepack

Version:

Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.

47 lines (37 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReferenceMap = void 0; /** * 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. */ /* strict */ // A map with an incrementing counter as the keys // Used to store references to variable collections since DebugProtocol // specifies fetching variable collections via unique IDs class ReferenceMap { constructor() { this._counter = 0; this._mapping = new Map(); } add(value) { this._counter++; this._mapping.set(this._counter, value); return this._counter; } get(reference) { return this._mapping.get(reference); } clean() { this._counter = 0; this._mapping = new Map(); } } exports.ReferenceMap = ReferenceMap; //# sourceMappingURL=ReferenceMap.js.map