{"id":"UBHQ","dependencies":[{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/package.json","includedInParent":true,"mtime":1545395749058},{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/package.json","includedInParent":true,"mtime":1545395355516},{"name":"./SymbolTreeNode","loc":{"line":8,"column":31},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/SymbolTree.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/SymbolTreeNode.js"},{"name":"./TreePosition","loc":{"line":9,"column":29},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/SymbolTree.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/TreePosition.js"},{"name":"./TreeIterator","loc":{"line":10,"column":29},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/SymbolTree.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/symbol-tree/lib/TreeIterator.js"}],"generated":{"js":"\"use strict\";const e=require(\"./SymbolTreeNode\"),i=require(\"./TreePosition\"),t=require(\"./TreeIterator\");function n(){return!0}function r(e,i){return e[e.length-1-i]}class s{constructor(e){this.symbol=Symbol(e||\"SymbolTree data\")}initialize(e){return this._node(e),e}_node(i){if(!i)return null;const t=i[this.symbol];return t||(i[this.symbol]=new e)}hasChildren(e){return this._node(e).hasChildren}firstChild(e){return this._node(e).firstChild}lastChild(e){return this._node(e).lastChild}previousSibling(e){return this._node(e).previousSibling}nextSibling(e){return this._node(e).nextSibling}parent(e){return this._node(e).parent}lastInclusiveDescendant(e){let i,t=e;for(;i=this._node(t).lastChild;)t=i;return t}preceding(e,i){if(e===(i&&i.root))return null;const t=this._node(e).previousSibling;return t?this.lastInclusiveDescendant(t):this._node(e).parent}following(e,i){const t=i&&i.root,n=!(i&&i.skipChildren)&&this._node(e).firstChild;if(n)return n;let r=e;do{if(r===t)return null;const e=this._node(r).nextSibling;if(e)return e;r=this._node(r).parent}while(r);return null}childrenToArray(e,i){const t=i&&i.array||[],r=i&&i.filter||n,s=i&&i.thisArg||void 0,o=this._node(e);let l=o.firstChild,h=0;for(;l;){const e=this._node(l);e.setCachedIndex(o,h),r.call(s,l)&&t.push(l),l=e.nextSibling,++h}return t}ancestorsToArray(e,i){const t=i&&i.array||[],r=i&&i.filter||n,s=i&&i.thisArg||void 0;let o=e;for(;o;)r.call(s,o)&&t.push(o),o=this._node(o).parent;return t}treeToArray(e,i){const t=i&&i.array||[],r=i&&i.filter||n,s=i&&i.thisArg||void 0;let o=e;for(;o;)r.call(s,o)&&t.push(o),o=this.following(o,{root:e});return t}childrenIterator(e,i){const n=i&&i.reverse,r=this._node(e);return new t(this,e,n?r.lastChild:r.firstChild,n?t.PREV:t.NEXT)}previousSiblingsIterator(e){return new t(this,e,this._node(e).previousSibling,t.PREV)}nextSiblingsIterator(e){return new t(this,e,this._node(e).nextSibling,t.NEXT)}ancestorsIterator(e){return new t(this,e,e,t.PARENT)}treeIterator(e,i){const n=i&&i.reverse;return new t(this,e,n?this.lastInclusiveDescendant(e):e,n?t.PRECEDING:t.FOLLOWING)}index(e){const i=this._node(e),t=this._node(i.parent);if(!t)return-1;let n=i.getCachedIndex(t);if(n>=0)return n;n=0;let r=t.firstChild;if(t.childIndexCachedUpTo){const e=this._node(t.childIndexCachedUpTo);r=e.nextSibling,n=e.getCachedIndex(t)+1}for(;r;){const i=this._node(r);if(i.setCachedIndex(t,n),r===e)break;++n,r=i.nextSibling}return t.childIndexCachedUpTo=e,n}childrenCount(e){const i=this._node(e);return i.lastChild?this.index(i.lastChild)+1:0}compareTreePosition(e,t){if(e===t)return 0;const n=[];{let r=e;for(;r;){if(r===t)return i.CONTAINS|i.PRECEDING;n.push(r),r=this.parent(r)}}const s=[];{let n=t;for(;n;){if(n===e)return i.CONTAINED_BY|i.FOLLOWING;s.push(n),n=this.parent(n)}}const o=r(n,0);if(!o||o!==r(s,0))return i.DISCONNECTED;let l=0;const h=Math.min(n.length,s.length);for(let i=0;i\n */\n\nconst SymbolTreeNode = require('./SymbolTreeNode');\nconst TreePosition = require('./TreePosition');\nconst TreeIterator = require('./TreeIterator');\n\nfunction returnTrue() {\n return true;\n}\n\nfunction reverseArrayIndex(array, reverseIndex) {\n return array[array.length - 1 - reverseIndex]; // no need to check `index >= 0`\n}\n\nclass SymbolTree {\n\n /**\n * @constructor\n * @alias module:symbol-tree\n * @param {string} [description='SymbolTree data'] Description used for the Symbol\n */\n constructor(description) {\n this.symbol = Symbol(description || 'SymbolTree data');\n }\n\n /**\n * You can use this function to (optionally) initialize an object right after its creation,\n * to take advantage of V8's fast properties. Also useful if you would like to\n * freeze your object.\n *\n * `O(1)`\n *\n * @method\n * @alias module:symbol-tree#initialize\n * @param {Object} object\n * @return {Object} object\n */\n initialize(object) {\n this._node(object);\n\n return object;\n }\n\n _node(object) {\n if (!object) {\n return null;\n }\n\n const node = object[this.symbol];\n\n if (node) {\n return node;\n }\n\n return (object[this.symbol] = new SymbolTreeNode());\n }\n\n /**\n * Returns `true` if the object has any children. Otherwise it returns `false`.\n *\n * * `O(1)`\n *\n * @method hasChildren\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Boolean}\n */\n hasChildren(object) {\n return this._node(object).hasChildren;\n }\n\n /**\n * Returns the first child of the given object.\n *\n * * `O(1)`\n *\n * @method firstChild\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n firstChild(object) {\n return this._node(object).firstChild;\n }\n\n /**\n * Returns the last child of the given object.\n *\n * * `O(1)`\n *\n * @method lastChild\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n lastChild(object) {\n return this._node(object).lastChild;\n }\n\n /**\n * Returns the previous sibling of the given object.\n *\n * * `O(1)`\n *\n * @method previousSibling\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n previousSibling(object) {\n return this._node(object).previousSibling;\n }\n\n /**\n * Returns the next sibling of the given object.\n *\n * * `O(1)`\n *\n * @method nextSibling\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n nextSibling(object) {\n return this._node(object).nextSibling;\n }\n\n /**\n * Return the parent of the given object.\n *\n * * `O(1)`\n *\n * @method parent\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n parent(object) {\n return this._node(object).parent;\n }\n\n /**\n * Find the inclusive descendant that is last in tree order of the given object.\n *\n * * `O(n)` (worst case) where `n` is the depth of the subtree of `object`\n *\n * @method lastInclusiveDescendant\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object}\n */\n lastInclusiveDescendant(object) {\n let lastChild;\n let current = object;\n\n while ((lastChild = this._node(current).lastChild)) {\n current = lastChild;\n }\n\n return current;\n }\n\n /**\n * Find the preceding object (A) of the given object (B).\n * An object A is preceding an object B if A and B are in the same tree\n * and A comes before B in tree order.\n *\n * * `O(n)` (worst case)\n * * `O(1)` (amortized when walking the entire tree)\n *\n * @method preceding\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @param {Object} [options]\n * @param {Object} [options.root] If set, `root` must be an inclusive ancestor\n * of the return value (or else null is returned). This check _assumes_\n * that `root` is also an inclusive ancestor of the given `object`\n * @return {?Object}\n */\n preceding(object, options) {\n const treeRoot = options && options.root;\n\n if (object === treeRoot) {\n return null;\n }\n\n const previousSibling = this._node(object).previousSibling;\n\n if (previousSibling) {\n return this.lastInclusiveDescendant(previousSibling);\n }\n\n // if there is no previous sibling return the parent (might be null)\n return this._node(object).parent;\n }\n\n /**\n * Find the following object (A) of the given object (B).\n * An object A is following an object B if A and B are in the same tree\n * and A comes after B in tree order.\n *\n * * `O(n)` (worst case) where `n` is the amount of objects in the entire tree\n * * `O(1)` (amortized when walking the entire tree)\n *\n * @method following\n * @memberOf module:symbol-tree#\n * @param {!Object} object\n * @param {Object} [options]\n * @param {Object} [options.root] If set, `root` must be an inclusive ancestor\n * of the return value (or else null is returned). This check _assumes_\n * that `root` is also an inclusive ancestor of the given `object`\n * @param {Boolean} [options.skipChildren=false] If set, ignore the children of `object`\n * @return {?Object}\n */\n following(object, options) {\n const treeRoot = options && options.root;\n const skipChildren = options && options.skipChildren;\n\n const firstChild = !skipChildren && this._node(object).firstChild;\n\n if (firstChild) {\n return firstChild;\n }\n\n let current = object;\n\n do {\n if (current === treeRoot) {\n return null;\n }\n\n const nextSibling = this._node(current).nextSibling;\n\n if (nextSibling) {\n return nextSibling;\n }\n\n current = this._node(current).parent;\n } while (current);\n\n return null;\n }\n\n /**\n * Append all children of the given object to an array.\n *\n * * `O(n)` where `n` is the amount of children of the given `parent`\n *\n * @method childrenToArray\n * @memberOf module:symbol-tree#\n * @param {Object} parent\n * @param {Object} [options]\n * @param {Object[]} [options.array=[]]\n * @param {Function} [options.filter] Function to test each object before it is added to the array.\n * Invoked with arguments (object). Should return `true` if an object\n * is to be included.\n * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.\n * @return {Object[]}\n */\n childrenToArray(parent, options) {\n const array = (options && options.array) || [];\n const filter = (options && options.filter) || returnTrue;\n const thisArg = (options && options.thisArg) || undefined;\n\n const parentNode = this._node(parent);\n let object = parentNode.firstChild;\n let index = 0;\n\n while (object) {\n const node = this._node(object);\n node.setCachedIndex(parentNode, index);\n\n if (filter.call(thisArg, object)) {\n array.push(object);\n }\n\n object = node.nextSibling;\n ++index;\n }\n\n return array;\n }\n\n /**\n * Append all inclusive ancestors of the given object to an array.\n *\n * * `O(n)` where `n` is the amount of ancestors of the given `object`\n *\n * @method ancestorsToArray\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @param {Object} [options]\n * @param {Object[]} [options.array=[]]\n * @param {Function} [options.filter] Function to test each object before it is added to the array.\n * Invoked with arguments (object). Should return `true` if an object\n * is to be included.\n * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.\n * @return {Object[]}\n */\n ancestorsToArray(object, options) {\n const array = (options && options.array) || [];\n const filter = (options && options.filter) || returnTrue;\n const thisArg = (options && options.thisArg) || undefined;\n\n let ancestor = object;\n\n while (ancestor) {\n if (filter.call(thisArg, ancestor)) {\n array.push(ancestor);\n }\n ancestor = this._node(ancestor).parent;\n }\n\n return array;\n }\n\n /**\n * Append all descendants of the given object to an array (in tree order).\n *\n * * `O(n)` where `n` is the amount of objects in the sub-tree of the given `object`\n *\n * @method treeToArray\n * @memberOf module:symbol-tree#\n * @param {Object} root\n * @param {Object} [options]\n * @param {Object[]} [options.array=[]]\n * @param {Function} [options.filter] Function to test each object before it is added to the array.\n * Invoked with arguments (object). Should return `true` if an object\n * is to be included.\n * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.\n * @return {Object[]}\n */\n treeToArray(root, options) {\n const array = (options && options.array) || [];\n const filter = (options && options.filter) || returnTrue;\n const thisArg = (options && options.thisArg) || undefined;\n\n let object = root;\n\n while (object) {\n if (filter.call(thisArg, object)) {\n array.push(object);\n }\n object = this.following(object, {root: root});\n }\n\n return array;\n }\n\n /**\n * Iterate over all children of the given object\n *\n * * `O(1)` for a single iteration\n *\n * @method childrenIterator\n * @memberOf module:symbol-tree#\n * @param {Object} parent\n * @param {Object} [options]\n * @param {Boolean} [options.reverse=false]\n * @return {Object} An iterable iterator (ES6)\n */\n childrenIterator(parent, options) {\n const reverse = options && options.reverse;\n const parentNode = this._node(parent);\n\n return new TreeIterator(\n this,\n parent,\n reverse ? parentNode.lastChild : parentNode.firstChild,\n reverse ? TreeIterator.PREV : TreeIterator.NEXT\n );\n }\n\n /**\n * Iterate over all the previous siblings of the given object. (in reverse tree order)\n *\n * * `O(1)` for a single iteration\n *\n * @method previousSiblingsIterator\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object} An iterable iterator (ES6)\n */\n previousSiblingsIterator(object) {\n return new TreeIterator(\n this,\n object,\n this._node(object).previousSibling,\n TreeIterator.PREV\n );\n }\n\n /**\n * Iterate over all the next siblings of the given object. (in tree order)\n *\n * * `O(1)` for a single iteration\n *\n * @method nextSiblingsIterator\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object} An iterable iterator (ES6)\n */\n nextSiblingsIterator(object) {\n return new TreeIterator(\n this,\n object,\n this._node(object).nextSibling,\n TreeIterator.NEXT\n );\n }\n\n /**\n * Iterate over all inclusive ancestors of the given object\n *\n * * `O(1)` for a single iteration\n *\n * @method ancestorsIterator\n * @memberOf module:symbol-tree#\n * @param {Object} object\n * @return {Object} An iterable iterator (ES6)\n */\n ancestorsIterator(object) {\n return new TreeIterator(\n this,\n object,\n object,\n TreeIterator.PARENT\n );\n }\n\n /**\n * Iterate over all descendants of the given object (in tree order).\n *\n * Where `n` is the amount of objects in the sub-tree of the given `root`:\n *\n * * `O(n)` (worst case for a single iteration)\n * * `O(n)` (amortized, when completing the iterator)\n *\n * @method treeIterator\n * @memberOf module:symbol-tree#\n * @param {Object} root\n * @param {Object} options\n * @param {Boolean} [options.reverse=false]\n * @return {Object} An iterable iterator (ES6)\n */\n treeIterator(root, options) {\n const reverse = options && options.reverse;\n\n return new TreeIterator(\n this,\n root,\n reverse ? this.lastInclusiveDescendant(root) : root,\n reverse ? TreeIterator.PRECEDING : TreeIterator.FOLLOWING\n );\n }\n\n /**\n * Find the index of the given object (the number of preceding siblings).\n *\n * * `O(n)` where `n` is the amount of preceding siblings\n * * `O(1)` (amortized, if the tree is not modified)\n *\n * @method index\n * @memberOf module:symbol-tree#\n * @param {Object} child\n * @return {Number} The number of preceding siblings, or -1 if the object has no parent\n */\n index(child) {\n const childNode = this._node(child);\n const parentNode = this._node(childNode.parent);\n\n if (!parentNode) {\n // In principal, you could also find out the number of preceding siblings\n // for objects that do not have a parent. This method limits itself only to\n // objects that have a parent because that lets us optimize more.\n return -1;\n }\n\n let currentIndex = childNode.getCachedIndex(parentNode);\n\n if (currentIndex >= 0) {\n return currentIndex;\n }\n\n currentIndex = 0;\n let object = parentNode.firstChild;\n\n if (parentNode.childIndexCachedUpTo) {\n const cachedUpToNode = this._node(parentNode.childIndexCachedUpTo);\n object = cachedUpToNode.nextSibling;\n currentIndex = cachedUpToNode.getCachedIndex(parentNode) + 1;\n }\n\n while (object) {\n const node = this._node(object);\n node.setCachedIndex(parentNode, currentIndex);\n\n if (object === child) {\n break;\n }\n\n ++currentIndex;\n object = node.nextSibling;\n }\n\n parentNode.childIndexCachedUpTo = child;\n\n return currentIndex;\n }\n\n /**\n * Calculate the number of children.\n *\n * * `O(n)` where `n` is the amount of children\n * * `O(1)` (amortized, if the tree is not modified)\n *\n * @method childrenCount\n * @memberOf module:symbol-tree#\n * @param {Object} parent\n * @return {Number}\n */\n childrenCount(parent) {\n const parentNode = this._node(parent);\n\n if (!parentNode.lastChild) {\n return 0;\n }\n\n return this.index(parentNode.lastChild) + 1;\n }\n\n /**\n * Compare the position of an object relative to another object. A bit set is returned:\n *\n * \n *\n * The semantics are the same as compareDocumentPosition in DOM, with the exception that\n * DISCONNECTED never occurs with any other bit.\n *\n * where `n` and `m` are the amount of ancestors of `left` and `right`;\n * where `o` is the amount of children of the lowest common ancestor of `left` and `right`:\n *\n * * `O(n + m + o)` (worst case)\n * * `O(n + m)` (amortized, if the tree is not modified)\n *\n * @method compareTreePosition\n * @memberOf module:symbol-tree#\n * @param {Object} left\n * @param {Object} right\n * @return {Number}\n */\n compareTreePosition(left, right) {\n // In DOM terms:\n // left = reference / context object\n // right = other\n\n if (left === right) {\n return 0;\n }\n\n /* jshint -W016 */\n\n const leftAncestors = []; { // inclusive\n let leftAncestor = left;\n\n while (leftAncestor) {\n if (leftAncestor === right) {\n return TreePosition.CONTAINS | TreePosition.PRECEDING;\n // other is ancestor of reference\n }\n\n leftAncestors.push(leftAncestor);\n leftAncestor = this.parent(leftAncestor);\n }\n }\n\n\n const rightAncestors = []; {\n let rightAncestor = right;\n\n while (rightAncestor) {\n if (rightAncestor === left) {\n return TreePosition.CONTAINED_BY | TreePosition.FOLLOWING;\n }\n\n rightAncestors.push(rightAncestor);\n rightAncestor = this.parent(rightAncestor);\n }\n }\n\n\n const root = reverseArrayIndex(leftAncestors, 0);\n\n if (!root || root !== reverseArrayIndex(rightAncestors, 0)) {\n // note: unlike DOM, preceding / following is not set here\n return TreePosition.DISCONNECTED;\n }\n\n // find the lowest common ancestor\n let commonAncestorIndex = 0;\n const ancestorsMinLength = Math.min(leftAncestors.length, rightAncestors.length);\n\n for (let i = 0; i < ancestorsMinLength; ++i) {\n const leftAncestor = reverseArrayIndex(leftAncestors, i);\n const rightAncestor = reverseArrayIndex(rightAncestors, i);\n\n if (leftAncestor !== rightAncestor) {\n break;\n }\n\n commonAncestorIndex = i;\n }\n\n // indexes within the common ancestor\n const leftIndex = this.index(reverseArrayIndex(leftAncestors, commonAncestorIndex + 1));\n const rightIndex = this.index(reverseArrayIndex(rightAncestors, commonAncestorIndex + 1));\n\n return rightIndex < leftIndex\n ? TreePosition.PRECEDING\n : TreePosition.FOLLOWING;\n }\n\n /**\n * Remove the object from this tree.\n * Has no effect if already removed.\n *\n * * `O(1)`\n *\n * @method remove\n * @memberOf module:symbol-tree#\n * @param {Object} removeObject\n * @return {Object} removeObject\n */\n remove(removeObject) {\n const removeNode = this._node(removeObject);\n const parentNode = this._node(removeNode.parent);\n const prevNode = this._node(removeNode.previousSibling);\n const nextNode = this._node(removeNode.nextSibling);\n\n if (parentNode) {\n if (parentNode.firstChild === removeObject) {\n parentNode.firstChild = removeNode.nextSibling;\n }\n\n if (parentNode.lastChild === removeObject) {\n parentNode.lastChild = removeNode.previousSibling;\n }\n }\n\n if (prevNode) {\n prevNode.nextSibling = removeNode.nextSibling;\n }\n\n if (nextNode) {\n nextNode.previousSibling = removeNode.previousSibling;\n }\n\n removeNode.parent = null;\n removeNode.previousSibling = null;\n removeNode.nextSibling = null;\n\n if (parentNode) {\n parentNode.childrenChanged();\n }\n\n return removeObject;\n }\n\n /**\n * Insert the given object before the reference object.\n * `newObject` is now the previous sibling of `referenceObject`.\n *\n * * `O(1)`\n *\n * @method insertBefore\n * @memberOf module:symbol-tree#\n * @param {Object} referenceObject\n * @param {Object} newObject\n * @throws {Error} If the newObject is already present in this SymbolTree\n * @return {Object} newObject\n */\n insertBefore(referenceObject, newObject) {\n const referenceNode = this._node(referenceObject);\n const prevNode = this._node(referenceNode.previousSibling);\n const newNode = this._node(newObject);\n const parentNode = this._node(referenceNode.parent);\n\n if (newNode.isAttached) {\n throw Error('Given object is already present in this SymbolTree, remove it first');\n }\n\n newNode.parent = referenceNode.parent;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.nextSibling = referenceObject;\n referenceNode.previousSibling = newObject;\n\n if (prevNode) {\n prevNode.nextSibling = newObject;\n }\n\n if (parentNode && parentNode.firstChild === referenceObject) {\n parentNode.firstChild = newObject;\n }\n\n if (parentNode) {\n parentNode.childrenChanged();\n }\n\n return newObject;\n }\n\n /**\n * Insert the given object after the reference object.\n * `newObject` is now the next sibling of `referenceObject`.\n *\n * * `O(1)`\n *\n * @method insertAfter\n * @memberOf module:symbol-tree#\n * @param {Object} referenceObject\n * @param {Object} newObject\n * @throws {Error} If the newObject is already present in this SymbolTree\n * @return {Object} newObject\n */\n insertAfter(referenceObject, newObject) {\n const referenceNode = this._node(referenceObject);\n const nextNode = this._node(referenceNode.nextSibling);\n const newNode = this._node(newObject);\n const parentNode = this._node(referenceNode.parent);\n\n if (newNode.isAttached) {\n throw Error('Given object is already present in this SymbolTree, remove it first');\n }\n\n newNode.parent = referenceNode.parent;\n newNode.previousSibling = referenceObject;\n newNode.nextSibling = referenceNode.nextSibling;\n referenceNode.nextSibling = newObject;\n\n if (nextNode) {\n nextNode.previousSibling = newObject;\n }\n\n if (parentNode && parentNode.lastChild === referenceObject) {\n parentNode.lastChild = newObject;\n }\n\n if (parentNode) {\n parentNode.childrenChanged();\n }\n\n return newObject;\n }\n\n /**\n * Insert the given object as the first child of the given reference object.\n * `newObject` is now the first child of `referenceObject`.\n *\n * * `O(1)`\n *\n * @method prependChild\n * @memberOf module:symbol-tree#\n * @param {Object} referenceObject\n * @param {Object} newObject\n * @throws {Error} If the newObject is already present in this SymbolTree\n * @return {Object} newObject\n */\n prependChild(referenceObject, newObject) {\n const referenceNode = this._node(referenceObject);\n const newNode = this._node(newObject);\n\n if (newNode.isAttached) {\n throw Error('Given object is already present in this SymbolTree, remove it first');\n }\n\n if (referenceNode.hasChildren) {\n this.insertBefore(referenceNode.firstChild, newObject);\n }\n else {\n newNode.parent = referenceObject;\n referenceNode.firstChild = newObject;\n referenceNode.lastChild = newObject;\n referenceNode.childrenChanged();\n }\n\n return newObject;\n }\n\n /**\n * Insert the given object as the last child of the given reference object.\n * `newObject` is now the last child of `referenceObject`.\n *\n * * `O(1)`\n *\n * @method appendChild\n * @memberOf module:symbol-tree#\n * @param {Object} referenceObject\n * @param {Object} newObject\n * @throws {Error} If the newObject is already present in this SymbolTree\n * @return {Object} newObject\n */\n appendChild(referenceObject, newObject) {\n const referenceNode = this._node(referenceObject);\n const newNode = this._node(newObject);\n\n if (newNode.isAttached) {\n throw Error('Given object is already present in this SymbolTree, remove it first');\n }\n\n if (referenceNode.hasChildren) {\n this.insertAfter(referenceNode.lastChild, newObject);\n }\n else {\n newNode.parent = referenceObject;\n referenceNode.firstChild = newObject;\n referenceNode.lastChild = newObject;\n referenceNode.childrenChanged();\n }\n\n return newObject;\n }\n}\n\nmodule.exports = SymbolTree;\nSymbolTree.TreePosition = TreePosition;\n"},"lineCount":null}},"hash":"28f0c0b9ef5665e326e9e0fb081f45e7","cacheData":{"env":{}}}