dominator-tree-lazy-children.js (1715B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * The `DominatorTreeLazyChildren` is a placeholder that represents a future 9 * subtree in an existing `DominatorTreeNode` tree that is currently being 10 * incrementally fetched from the `HeapAnalysesWorker`. 11 * 12 * @param {NodeId} parentNodeId 13 * @param {number} siblingIndex 14 */ 15 function DominatorTreeLazyChildren(parentNodeId, siblingIndex) { 16 this._parentNodeId = parentNodeId; 17 this._siblingIndex = siblingIndex; 18 } 19 20 /** 21 * Generate a unique key for this `DominatorTreeLazyChildren` instance. This can 22 * be used as the key in a hash table or as the `key` property for a React 23 * component, for example. 24 * 25 * @returns {string} 26 */ 27 DominatorTreeLazyChildren.prototype.key = function () { 28 return `dominator-tree-lazy-children-${this._parentNodeId}-${this._siblingIndex}`; 29 }; 30 31 /** 32 * Return true if this is a placeholder for the first child of its 33 * parent. Return false if it is a placeholder for loading more of its parent's 34 * children. 35 * 36 * @returns {boolean} 37 */ 38 DominatorTreeLazyChildren.prototype.isFirstChild = function () { 39 return this._siblingIndex === 0; 40 }; 41 42 /** 43 * Get this subtree's parent node's identifier. 44 * 45 * @returns {NodeId} 46 */ 47 DominatorTreeLazyChildren.prototype.parentNodeId = function () { 48 return this._parentNodeId; 49 }; 50 51 /** 52 * Get this subtree's index in its parent's children array. 53 * 54 * @returns {number} 55 */ 56 DominatorTreeLazyChildren.prototype.siblingIndex = function () { 57 return this._siblingIndex; 58 }; 59 60 module.exports = DominatorTreeLazyChildren;