summaryrefslogtreecommitdiff
path: root/school/node_modules/symbol-tree
diff options
context:
space:
mode:
Diffstat (limited to 'school/node_modules/symbol-tree')
-rw-r--r--school/node_modules/symbol-tree/LICENSE21
-rw-r--r--school/node_modules/symbol-tree/README.md545
-rw-r--r--school/node_modules/symbol-tree/lib/SymbolTree.js838
-rw-r--r--school/node_modules/symbol-tree/lib/SymbolTreeNode.js54
-rw-r--r--school/node_modules/symbol-tree/lib/TreeIterator.js69
-rw-r--r--school/node_modules/symbol-tree/lib/TreePosition.js11
-rw-r--r--school/node_modules/symbol-tree/package.json47
7 files changed, 1585 insertions, 0 deletions
diff --git a/school/node_modules/symbol-tree/LICENSE b/school/node_modules/symbol-tree/LICENSE
new file mode 100644
index 0000000..9b5796d
--- /dev/null
+++ b/school/node_modules/symbol-tree/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Joris van der Wel
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/school/node_modules/symbol-tree/README.md b/school/node_modules/symbol-tree/README.md
new file mode 100644
index 0000000..972db1a
--- /dev/null
+++ b/school/node_modules/symbol-tree/README.md
@@ -0,0 +1,545 @@
+symbol-tree
+===========
+[![Travis CI Build Status](https://api.travis-ci.org/jsdom/js-symbol-tree.svg?branch=master)](https://travis-ci.org/jsdom/js-symbol-tree) [![Coverage Status](https://coveralls.io/repos/github/jsdom/js-symbol-tree/badge.svg?branch=master)](https://coveralls.io/github/jsdom/js-symbol-tree?branch=master)
+
+Turn any collection of objects into its own efficient tree or linked list using `Symbol`.
+
+This library has been designed to provide an efficient backing data structure for DOM trees. You can also use this library as an efficient linked list. Any meta data is stored on your objects directly, which ensures any kind of insertion or deletion is performed in constant time. Because an ES6 `Symbol` is used, the meta data does not interfere with your object in any way.
+
+Node.js 4+, io.js and modern browsers are supported.
+
+Example
+-------
+A linked list:
+
+```javascript
+const SymbolTree = require('symbol-tree');
+const tree = new SymbolTree();
+
+let a = {foo: 'bar'}; // or `new Whatever()`
+let b = {foo: 'baz'};
+let c = {foo: 'qux'};
+
+tree.insertBefore(b, a); // insert a before b
+tree.insertAfter(b, c); // insert c after b
+
+console.log(tree.nextSibling(a) === b);
+console.log(tree.nextSibling(b) === c);
+console.log(tree.previousSibling(c) === b);
+
+tree.remove(b);
+console.log(tree.nextSibling(a) === c);
+```
+
+A tree:
+
+```javascript
+const SymbolTree = require('symbol-tree');
+const tree = new SymbolTree();
+
+let parent = {};
+let a = {};
+let b = {};
+let c = {};
+
+tree.prependChild(parent, a); // insert a as the first child
+tree.appendChild(parent,c ); // insert c as the last child
+tree.insertAfter(a, b); // insert b after a, it now has the same parent as a
+
+console.log(tree.firstChild(parent) === a);
+console.log(tree.nextSibling(tree.firstChild(parent)) === b);
+console.log(tree.lastChild(parent) === c);
+
+let grandparent = {};
+tree.prependChild(grandparent, parent);
+console.log(tree.firstChild(tree.firstChild(grandparent)) === a);
+```
+
+See [api.md](api.md) for more documentation.
+
+Testing
+-------
+Make sure you install the dependencies first:
+
+ npm install
+
+You can now run the unit tests by executing:
+
+ npm test
+
+The line and branch coverage should be 100%.
+
+API Documentation
+-----------------
+<a name="module_symbol-tree"></a>
+
+## symbol-tree
+**Author**: Joris van der Wel <joris@jorisvanderwel.com>
+
+* [symbol-tree](#module_symbol-tree)
+ * [SymbolTree](#exp_module_symbol-tree--SymbolTree) ⏏
+ * [new SymbolTree([description])](#new_module_symbol-tree--SymbolTree_new)
+ * [.initialize(object)](#module_symbol-tree--SymbolTree+initialize) ⇒ <code>Object</code>
+ * [.hasChildren(object)](#module_symbol-tree--SymbolTree+hasChildren) ⇒ <code>Boolean</code>
+ * [.firstChild(object)](#module_symbol-tree--SymbolTree+firstChild) ⇒ <code>Object</code>
+ * [.lastChild(object)](#module_symbol-tree--SymbolTree+lastChild) ⇒ <code>Object</code>
+ * [.previousSibling(object)](#module_symbol-tree--SymbolTree+previousSibling) ⇒ <code>Object</code>
+ * [.nextSibling(object)](#module_symbol-tree--SymbolTree+nextSibling) ⇒ <code>Object</code>
+ * [.parent(object)](#module_symbol-tree--SymbolTree+parent) ⇒ <code>Object</code>
+ * [.lastInclusiveDescendant(object)](#module_symbol-tree--SymbolTree+lastInclusiveDescendant) ⇒ <code>Object</code>
+ * [.preceding(object, [options])](#module_symbol-tree--SymbolTree+preceding) ⇒ <code>Object</code>
+ * [.following(object, [options])](#module_symbol-tree--SymbolTree+following) ⇒ <code>Object</code>
+ * [.childrenToArray(parent, [options])](#module_symbol-tree--SymbolTree+childrenToArray) ⇒ <code>Array.&lt;Object&gt;</code>
+ * [.ancestorsToArray(object, [options])](#module_symbol-tree--SymbolTree+ancestorsToArray) ⇒ <code>Array.&lt;Object&gt;</code>
+ * [.treeToArray(root, [options])](#module_symbol-tree--SymbolTree+treeToArray) ⇒ <code>Array.&lt;Object&gt;</code>
+ * [.childrenIterator(parent, [options])](#module_symbol-tree--SymbolTree+childrenIterator) ⇒ <code>Object</code>
+ * [.previousSiblingsIterator(object)](#module_symbol-tree--SymbolTree+previousSiblingsIterator) ⇒ <code>Object</code>
+ * [.nextSiblingsIterator(object)](#module_symbol-tree--SymbolTree+nextSiblingsIterator) ⇒ <code>Object</code>
+ * [.ancestorsIterator(object)](#module_symbol-tree--SymbolTree+ancestorsIterator) ⇒ <code>Object</code>
+ * [.treeIterator(root, options)](#module_symbol-tree--SymbolTree+treeIterator) ⇒ <code>Object</code>
+ * [.index(child)](#module_symbol-tree--SymbolTree+index) ⇒ <code>Number</code>
+ * [.childrenCount(parent)](#module_symbol-tree--SymbolTree+childrenCount) ⇒ <code>Number</code>
+ * [.compareTreePosition(left, right)](#module_symbol-tree--SymbolTree+compareTreePosition) ⇒ <code>Number</code>
+ * [.remove(removeObject)](#module_symbol-tree--SymbolTree+remove) ⇒ <code>Object</code>
+ * [.insertBefore(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertBefore) ⇒ <code>Object</code>
+ * [.insertAfter(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertAfter) ⇒ <code>Object</code>
+ * [.prependChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+prependChild) ⇒ <code>Object</code>
+ * [.appendChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+appendChild) ⇒ <code>Object</code>
+
+<a name="exp_module_symbol-tree--SymbolTree"></a>
+
+### SymbolTree ⏏
+**Kind**: Exported class
+<a name="new_module_symbol-tree--SymbolTree_new"></a>
+
+#### new SymbolTree([description])
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [description] | <code>string</code> | <code>&quot;&#x27;SymbolTree data&#x27;&quot;</code> | Description used for the Symbol |
+
+<a name="module_symbol-tree--SymbolTree+initialize"></a>
+
+#### symbolTree.initialize(object) ⇒ <code>Object</code>
+You can use this function to (optionally) initialize an object right after its creation,
+to take advantage of V8's fast properties. Also useful if you would like to
+freeze your object.
+
+`O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - object
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+hasChildren"></a>
+
+#### symbolTree.hasChildren(object) ⇒ <code>Boolean</code>
+Returns `true` if the object has any children. Otherwise it returns `false`.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+firstChild"></a>
+
+#### symbolTree.firstChild(object) ⇒ <code>Object</code>
+Returns the first child of the given object.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+lastChild"></a>
+
+#### symbolTree.lastChild(object) ⇒ <code>Object</code>
+Returns the last child of the given object.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+previousSibling"></a>
+
+#### symbolTree.previousSibling(object) ⇒ <code>Object</code>
+Returns the previous sibling of the given object.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+nextSibling"></a>
+
+#### symbolTree.nextSibling(object) ⇒ <code>Object</code>
+Returns the next sibling of the given object.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+parent"></a>
+
+#### symbolTree.parent(object) ⇒ <code>Object</code>
+Return the parent of the given object.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+lastInclusiveDescendant"></a>
+
+#### symbolTree.lastInclusiveDescendant(object) ⇒ <code>Object</code>
+Find the inclusive descendant that is last in tree order of the given object.
+
+* `O(n)` (worst case) where `n` is the depth of the subtree of `object`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+preceding"></a>
+
+#### symbolTree.preceding(object, [options]) ⇒ <code>Object</code>
+Find the preceding object (A) of the given object (B).
+An object A is preceding an object B if A and B are in the same tree
+and A comes before B in tree order.
+
+* `O(n)` (worst case)
+* `O(1)` (amortized when walking the entire tree)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| object | <code>Object</code> | |
+| [options] | <code>Object</code> | |
+| [options.root] | <code>Object</code> | If set, `root` must be an inclusive ancestor of the return value (or else null is returned). This check _assumes_ that `root` is also an inclusive ancestor of the given `object` |
+
+<a name="module_symbol-tree--SymbolTree+following"></a>
+
+#### symbolTree.following(object, [options]) ⇒ <code>Object</code>
+Find the following object (A) of the given object (B).
+An object A is following an object B if A and B are in the same tree
+and A comes after B in tree order.
+
+* `O(n)` (worst case) where `n` is the amount of objects in the entire tree
+* `O(1)` (amortized when walking the entire tree)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| object | <code>Object</code> | | |
+| [options] | <code>Object</code> | | |
+| [options.root] | <code>Object</code> | | If set, `root` must be an inclusive ancestor of the return value (or else null is returned). This check _assumes_ that `root` is also an inclusive ancestor of the given `object` |
+| [options.skipChildren] | <code>Boolean</code> | <code>false</code> | If set, ignore the children of `object` |
+
+<a name="module_symbol-tree--SymbolTree+childrenToArray"></a>
+
+#### symbolTree.childrenToArray(parent, [options]) ⇒ <code>Array.&lt;Object&gt;</code>
+Append all children of the given object to an array.
+
+* `O(n)` where `n` is the amount of children of the given `parent`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| parent | <code>Object</code> | | |
+| [options] | <code>Object</code> | | |
+| [options.array] | <code>Array.&lt;Object&gt;</code> | <code>[]</code> | |
+| [options.filter] | <code>function</code> | | Function to test each object before it is added to the array. Invoked with arguments (object). Should return `true` if an object is to be included. |
+| [options.thisArg] | <code>\*</code> | | Value to use as `this` when executing `filter`. |
+
+<a name="module_symbol-tree--SymbolTree+ancestorsToArray"></a>
+
+#### symbolTree.ancestorsToArray(object, [options]) ⇒ <code>Array.&lt;Object&gt;</code>
+Append all inclusive ancestors of the given object to an array.
+
+* `O(n)` where `n` is the amount of ancestors of the given `object`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| object | <code>Object</code> | | |
+| [options] | <code>Object</code> | | |
+| [options.array] | <code>Array.&lt;Object&gt;</code> | <code>[]</code> | |
+| [options.filter] | <code>function</code> | | Function to test each object before it is added to the array. Invoked with arguments (object). Should return `true` if an object is to be included. |
+| [options.thisArg] | <code>\*</code> | | Value to use as `this` when executing `filter`. |
+
+<a name="module_symbol-tree--SymbolTree+treeToArray"></a>
+
+#### symbolTree.treeToArray(root, [options]) ⇒ <code>Array.&lt;Object&gt;</code>
+Append all descendants of the given object to an array (in tree order).
+
+* `O(n)` where `n` is the amount of objects in the sub-tree of the given `object`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| root | <code>Object</code> | | |
+| [options] | <code>Object</code> | | |
+| [options.array] | <code>Array.&lt;Object&gt;</code> | <code>[]</code> | |
+| [options.filter] | <code>function</code> | | Function to test each object before it is added to the array. Invoked with arguments (object). Should return `true` if an object is to be included. |
+| [options.thisArg] | <code>\*</code> | | Value to use as `this` when executing `filter`. |
+
+<a name="module_symbol-tree--SymbolTree+childrenIterator"></a>
+
+#### symbolTree.childrenIterator(parent, [options]) ⇒ <code>Object</code>
+Iterate over all children of the given object
+
+* `O(1)` for a single iteration
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - An iterable iterator (ES6)
+
+| Param | Type | Default |
+| --- | --- | --- |
+| parent | <code>Object</code> | |
+| [options] | <code>Object</code> | |
+| [options.reverse] | <code>Boolean</code> | <code>false</code> |
+
+<a name="module_symbol-tree--SymbolTree+previousSiblingsIterator"></a>
+
+#### symbolTree.previousSiblingsIterator(object) ⇒ <code>Object</code>
+Iterate over all the previous siblings of the given object. (in reverse tree order)
+
+* `O(1)` for a single iteration
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - An iterable iterator (ES6)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+nextSiblingsIterator"></a>
+
+#### symbolTree.nextSiblingsIterator(object) ⇒ <code>Object</code>
+Iterate over all the next siblings of the given object. (in tree order)
+
+* `O(1)` for a single iteration
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - An iterable iterator (ES6)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+ancestorsIterator"></a>
+
+#### symbolTree.ancestorsIterator(object) ⇒ <code>Object</code>
+Iterate over all inclusive ancestors of the given object
+
+* `O(1)` for a single iteration
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - An iterable iterator (ES6)
+
+| Param | Type |
+| --- | --- |
+| object | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+treeIterator"></a>
+
+#### symbolTree.treeIterator(root, options) ⇒ <code>Object</code>
+Iterate over all descendants of the given object (in tree order).
+
+Where `n` is the amount of objects in the sub-tree of the given `root`:
+
+* `O(n)` (worst case for a single iteration)
+* `O(n)` (amortized, when completing the iterator)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - An iterable iterator (ES6)
+
+| Param | Type | Default |
+| --- | --- | --- |
+| root | <code>Object</code> | |
+| options | <code>Object</code> | |
+| [options.reverse] | <code>Boolean</code> | <code>false</code> |
+
+<a name="module_symbol-tree--SymbolTree+index"></a>
+
+#### symbolTree.index(child) ⇒ <code>Number</code>
+Find the index of the given object (the number of preceding siblings).
+
+* `O(n)` where `n` is the amount of preceding siblings
+* `O(1)` (amortized, if the tree is not modified)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Number</code> - The number of preceding siblings, or -1 if the object has no parent
+
+| Param | Type |
+| --- | --- |
+| child | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+childrenCount"></a>
+
+#### symbolTree.childrenCount(parent) ⇒ <code>Number</code>
+Calculate the number of children.
+
+* `O(n)` where `n` is the amount of children
+* `O(1)` (amortized, if the tree is not modified)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| parent | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+compareTreePosition"></a>
+
+#### symbolTree.compareTreePosition(left, right) ⇒ <code>Number</code>
+Compare the position of an object relative to another object. A bit set is returned:
+
+<ul>
+ <li>DISCONNECTED : 1</li>
+ <li>PRECEDING : 2</li>
+ <li>FOLLOWING : 4</li>
+ <li>CONTAINS : 8</li>
+ <li>CONTAINED_BY : 16</li>
+</ul>
+
+The semantics are the same as compareDocumentPosition in DOM, with the exception that
+DISCONNECTED never occurs with any other bit.
+
+where `n` and `m` are the amount of ancestors of `left` and `right`;
+where `o` is the amount of children of the lowest common ancestor of `left` and `right`:
+
+* `O(n + m + o)` (worst case)
+* `O(n + m)` (amortized, if the tree is not modified)
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+
+| Param | Type |
+| --- | --- |
+| left | <code>Object</code> |
+| right | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+remove"></a>
+
+#### symbolTree.remove(removeObject) ⇒ <code>Object</code>
+Remove the object from this tree.
+Has no effect if already removed.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - removeObject
+
+| Param | Type |
+| --- | --- |
+| removeObject | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+insertBefore"></a>
+
+#### symbolTree.insertBefore(referenceObject, newObject) ⇒ <code>Object</code>
+Insert the given object before the reference object.
+`newObject` is now the previous sibling of `referenceObject`.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - newObject
+**Throws**:
+
+- <code>Error</code> If the newObject is already present in this SymbolTree
+
+
+| Param | Type |
+| --- | --- |
+| referenceObject | <code>Object</code> |
+| newObject | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+insertAfter"></a>
+
+#### symbolTree.insertAfter(referenceObject, newObject) ⇒ <code>Object</code>
+Insert the given object after the reference object.
+`newObject` is now the next sibling of `referenceObject`.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - newObject
+**Throws**:
+
+- <code>Error</code> If the newObject is already present in this SymbolTree
+
+
+| Param | Type |
+| --- | --- |
+| referenceObject | <code>Object</code> |
+| newObject | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+prependChild"></a>
+
+#### symbolTree.prependChild(referenceObject, newObject) ⇒ <code>Object</code>
+Insert the given object as the first child of the given reference object.
+`newObject` is now the first child of `referenceObject`.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - newObject
+**Throws**:
+
+- <code>Error</code> If the newObject is already present in this SymbolTree
+
+
+| Param | Type |
+| --- | --- |
+| referenceObject | <code>Object</code> |
+| newObject | <code>Object</code> |
+
+<a name="module_symbol-tree--SymbolTree+appendChild"></a>
+
+#### symbolTree.appendChild(referenceObject, newObject) ⇒ <code>Object</code>
+Insert the given object as the last child of the given reference object.
+`newObject` is now the last child of `referenceObject`.
+
+* `O(1)`
+
+**Kind**: instance method of [<code>SymbolTree</code>](#exp_module_symbol-tree--SymbolTree)
+**Returns**: <code>Object</code> - newObject
+**Throws**:
+
+- <code>Error</code> If the newObject is already present in this SymbolTree
+
+
+| Param | Type |
+| --- | --- |
+| referenceObject | <code>Object</code> |
+| newObject | <code>Object</code> |
+
diff --git a/school/node_modules/symbol-tree/lib/SymbolTree.js b/school/node_modules/symbol-tree/lib/SymbolTree.js
new file mode 100644
index 0000000..b2b8f2e
--- /dev/null
+++ b/school/node_modules/symbol-tree/lib/SymbolTree.js
@@ -0,0 +1,838 @@
+'use strict';
+
+/**
+ * @module symbol-tree
+ * @author Joris van der Wel <joris@jorisvanderwel.com>
+ */
+
+const SymbolTreeNode = require('./SymbolTreeNode');
+const TreePosition = require('./TreePosition');
+const TreeIterator = require('./TreeIterator');
+
+function returnTrue() {
+ return true;
+}
+
+function reverseArrayIndex(array, reverseIndex) {
+ return array[array.length - 1 - reverseIndex]; // no need to check `index >= 0`
+}
+
+class SymbolTree {
+
+ /**
+ * @constructor
+ * @alias module:symbol-tree
+ * @param {string} [description='SymbolTree data'] Description used for the Symbol
+ */
+ constructor(description) {
+ this.symbol = Symbol(description || 'SymbolTree data');
+ }
+
+ /**
+ * You can use this function to (optionally) initialize an object right after its creation,
+ * to take advantage of V8's fast properties. Also useful if you would like to
+ * freeze your object.
+ *
+ * `O(1)`
+ *
+ * @method
+ * @alias module:symbol-tree#initialize
+ * @param {Object} object
+ * @return {Object} object
+ */
+ initialize(object) {
+ this._node(object);
+
+ return object;
+ }
+
+ _node(object) {
+ if (!object) {
+ return null;
+ }
+
+ const node = object[this.symbol];
+
+ if (node) {
+ return node;
+ }
+
+ return (object[this.symbol] = new SymbolTreeNode());
+ }
+
+ /**
+ * Returns `true` if the object has any children. Otherwise it returns `false`.
+ *
+ * * `O(1)`
+ *
+ * @method hasChildren
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Boolean}
+ */
+ hasChildren(object) {
+ return this._node(object).hasChildren;
+ }
+
+ /**
+ * Returns the first child of the given object.
+ *
+ * * `O(1)`
+ *
+ * @method firstChild
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ firstChild(object) {
+ return this._node(object).firstChild;
+ }
+
+ /**
+ * Returns the last child of the given object.
+ *
+ * * `O(1)`
+ *
+ * @method lastChild
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ lastChild(object) {
+ return this._node(object).lastChild;
+ }
+
+ /**
+ * Returns the previous sibling of the given object.
+ *
+ * * `O(1)`
+ *
+ * @method previousSibling
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ previousSibling(object) {
+ return this._node(object).previousSibling;
+ }
+
+ /**
+ * Returns the next sibling of the given object.
+ *
+ * * `O(1)`
+ *
+ * @method nextSibling
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ nextSibling(object) {
+ return this._node(object).nextSibling;
+ }
+
+ /**
+ * Return the parent of the given object.
+ *
+ * * `O(1)`
+ *
+ * @method parent
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ parent(object) {
+ return this._node(object).parent;
+ }
+
+ /**
+ * Find the inclusive descendant that is last in tree order of the given object.
+ *
+ * * `O(n)` (worst case) where `n` is the depth of the subtree of `object`
+ *
+ * @method lastInclusiveDescendant
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object}
+ */
+ lastInclusiveDescendant(object) {
+ let lastChild;
+ let current = object;
+
+ while ((lastChild = this._node(current).lastChild)) {
+ current = lastChild;
+ }
+
+ return current;
+ }
+
+ /**
+ * Find the preceding object (A) of the given object (B).
+ * An object A is preceding an object B if A and B are in the same tree
+ * and A comes before B in tree order.
+ *
+ * * `O(n)` (worst case)
+ * * `O(1)` (amortized when walking the entire tree)
+ *
+ * @method preceding
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @param {Object} [options]
+ * @param {Object} [options.root] If set, `root` must be an inclusive ancestor
+ * of the return value (or else null is returned). This check _assumes_
+ * that `root` is also an inclusive ancestor of the given `object`
+ * @return {?Object}
+ */
+ preceding(object, options) {
+ const treeRoot = options && options.root;
+
+ if (object === treeRoot) {
+ return null;
+ }
+
+ const previousSibling = this._node(object).previousSibling;
+
+ if (previousSibling) {
+ return this.lastInclusiveDescendant(previousSibling);
+ }
+
+ // if there is no previous sibling return the parent (might be null)
+ return this._node(object).parent;
+ }
+
+ /**
+ * Find the following object (A) of the given object (B).
+ * An object A is following an object B if A and B are in the same tree
+ * and A comes after B in tree order.
+ *
+ * * `O(n)` (worst case) where `n` is the amount of objects in the entire tree
+ * * `O(1)` (amortized when walking the entire tree)
+ *
+ * @method following
+ * @memberOf module:symbol-tree#
+ * @param {!Object} object
+ * @param {Object} [options]
+ * @param {Object} [options.root] If set, `root` must be an inclusive ancestor
+ * of the return value (or else null is returned). This check _assumes_
+ * that `root` is also an inclusive ancestor of the given `object`
+ * @param {Boolean} [options.skipChildren=false] If set, ignore the children of `object`
+ * @return {?Object}
+ */
+ following(object, options) {
+ const treeRoot = options && options.root;
+ const skipChildren = options && options.skipChildren;
+
+ const firstChild = !skipChildren && this._node(object).firstChild;
+
+ if (firstChild) {
+ return firstChild;
+ }
+
+ let current = object;
+
+ do {
+ if (current === treeRoot) {
+ return null;
+ }
+
+ const nextSibling = this._node(current).nextSibling;
+
+ if (nextSibling) {
+ return nextSibling;
+ }
+
+ current = this._node(current).parent;
+ } while (current);
+
+ return null;
+ }
+
+ /**
+ * Append all children of the given object to an array.
+ *
+ * * `O(n)` where `n` is the amount of children of the given `parent`
+ *
+ * @method childrenToArray
+ * @memberOf module:symbol-tree#
+ * @param {Object} parent
+ * @param {Object} [options]
+ * @param {Object[]} [options.array=[]]
+ * @param {Function} [options.filter] Function to test each object before it is added to the array.
+ * Invoked with arguments (object). Should return `true` if an object
+ * is to be included.
+ * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
+ * @return {Object[]}
+ */
+ childrenToArray(parent, options) {
+ const array = (options && options.array) || [];
+ const filter = (options && options.filter) || returnTrue;
+ const thisArg = (options && options.thisArg) || undefined;
+
+ const parentNode = this._node(parent);
+ let object = parentNode.firstChild;
+ let index = 0;
+
+ while (object) {
+ const node = this._node(object);
+ node.setCachedIndex(parentNode, index);
+
+ if (filter.call(thisArg, object)) {
+ array.push(object);
+ }
+
+ object = node.nextSibling;
+ ++index;
+ }
+
+ return array;
+ }
+
+ /**
+ * Append all inclusive ancestors of the given object to an array.
+ *
+ * * `O(n)` where `n` is the amount of ancestors of the given `object`
+ *
+ * @method ancestorsToArray
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @param {Object} [options]
+ * @param {Object[]} [options.array=[]]
+ * @param {Function} [options.filter] Function to test each object before it is added to the array.
+ * Invoked with arguments (object). Should return `true` if an object
+ * is to be included.
+ * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
+ * @return {Object[]}
+ */
+ ancestorsToArray(object, options) {
+ const array = (options && options.array) || [];
+ const filter = (options && options.filter) || returnTrue;
+ const thisArg = (options && options.thisArg) || undefined;
+
+ let ancestor = object;
+
+ while (ancestor) {
+ if (filter.call(thisArg, ancestor)) {
+ array.push(ancestor);
+ }
+ ancestor = this._node(ancestor).parent;
+ }
+
+ return array;
+ }
+
+ /**
+ * Append all descendants of the given object to an array (in tree order).
+ *
+ * * `O(n)` where `n` is the amount of objects in the sub-tree of the given `object`
+ *
+ * @method treeToArray
+ * @memberOf module:symbol-tree#
+ * @param {Object} root
+ * @param {Object} [options]
+ * @param {Object[]} [options.array=[]]
+ * @param {Function} [options.filter] Function to test each object before it is added to the array.
+ * Invoked with arguments (object). Should return `true` if an object
+ * is to be included.
+ * @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
+ * @return {Object[]}
+ */
+ treeToArray(root, options) {
+ const array = (options && options.array) || [];
+ const filter = (options && options.filter) || returnTrue;
+ const thisArg = (options && options.thisArg) || undefined;
+
+ let object = root;
+
+ while (object) {
+ if (filter.call(thisArg, object)) {
+ array.push(object);
+ }
+ object = this.following(object, {root: root});
+ }
+
+ return array;
+ }
+
+ /**
+ * Iterate over all children of the given object
+ *
+ * * `O(1)` for a single iteration
+ *
+ * @method childrenIterator
+ * @memberOf module:symbol-tree#
+ * @param {Object} parent
+ * @param {Object} [options]
+ * @param {Boolean} [options.reverse=false]
+ * @return {Object} An iterable iterator (ES6)
+ */
+ childrenIterator(parent, options) {
+ const reverse = options && options.reverse;
+ const parentNode = this._node(parent);
+
+ return new TreeIterator(
+ this,
+ parent,
+ reverse ? parentNode.lastChild : parentNode.firstChild,
+ reverse ? TreeIterator.PREV : TreeIterator.NEXT
+ );
+ }
+
+ /**
+ * Iterate over all the previous siblings of the given object. (in reverse tree order)
+ *
+ * * `O(1)` for a single iteration
+ *
+ * @method previousSiblingsIterator
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object} An iterable iterator (ES6)
+ */
+ previousSiblingsIterator(object) {
+ return new TreeIterator(
+ this,
+ object,
+ this._node(object).previousSibling,
+ TreeIterator.PREV
+ );
+ }
+
+ /**
+ * Iterate over all the next siblings of the given object. (in tree order)
+ *
+ * * `O(1)` for a single iteration
+ *
+ * @method nextSiblingsIterator
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object} An iterable iterator (ES6)
+ */
+ nextSiblingsIterator(object) {
+ return new TreeIterator(
+ this,
+ object,
+ this._node(object).nextSibling,
+ TreeIterator.NEXT
+ );
+ }
+
+ /**
+ * Iterate over all inclusive ancestors of the given object
+ *
+ * * `O(1)` for a single iteration
+ *
+ * @method ancestorsIterator
+ * @memberOf module:symbol-tree#
+ * @param {Object} object
+ * @return {Object} An iterable iterator (ES6)
+ */
+ ancestorsIterator(object) {
+ return new TreeIterator(
+ this,
+ object,
+ object,
+ TreeIterator.PARENT
+ );
+ }
+
+ /**
+ * Iterate over all descendants of the given object (in tree order).
+ *
+ * Where `n` is the amount of objects in the sub-tree of the given `root`:
+ *
+ * * `O(n)` (worst case for a single iteration)
+ * * `O(n)` (amortized, when completing the iterator)
+ *
+ * @method treeIterator
+ * @memberOf module:symbol-tree#
+ * @param {Object} root
+ * @param {Object} options
+ * @param {Boolean} [options.reverse=false]
+ * @return {Object} An iterable iterator (ES6)
+ */
+ treeIterator(root, options) {
+ const reverse = options && options.reverse;
+
+ return new TreeIterator(
+ this,
+ root,
+ reverse ? this.lastInclusiveDescendant(root) : root,
+ reverse ? TreeIterator.PRECEDING : TreeIterator.FOLLOWING
+ );
+ }
+
+ /**
+ * Find the index of the given object (the number of preceding siblings).
+ *
+ * * `O(n)` where `n` is the amount of preceding siblings
+ * * `O(1)` (amortized, if the tree is not modified)
+ *
+ * @method index
+ * @memberOf module:symbol-tree#
+ * @param {Object} child
+ * @return {Number} The number of preceding siblings, or -1 if the object has no parent
+ */
+ index(child) {
+ const childNode = this._node(child);
+ const parentNode = this._node(childNode.parent);
+
+ if (!parentNode) {
+ // In principal, you could also find out the number of preceding siblings
+ // for objects that do not have a parent. This method limits itself only to
+ // objects that have a parent because that lets us optimize more.
+ return -1;
+ }
+
+ let currentIndex = childNode.getCachedIndex(parentNode);
+
+ if (currentIndex >= 0) {
+ return currentIndex;
+ }
+
+ currentIndex = 0;
+ let object = parentNode.firstChild;
+
+ if (parentNode.childIndexCachedUpTo) {
+ const cachedUpToNode = this._node(parentNode.childIndexCachedUpTo);
+ object = cachedUpToNode.nextSibling;
+ currentIndex = cachedUpToNode.getCachedIndex(parentNode) + 1;
+ }
+
+ while (object) {
+ const node = this._node(object);
+ node.setCachedIndex(parentNode, currentIndex);
+
+ if (object === child) {
+ break;
+ }
+
+ ++currentIndex;
+ object = node.nextSibling;
+ }
+
+ parentNode.childIndexCachedUpTo = child;
+
+ return currentIndex;
+ }
+
+ /**
+ * Calculate the number of children.
+ *
+ * * `O(n)` where `n` is the amount of children
+ * * `O(1)` (amortized, if the tree is not modified)
+ *
+ * @method childrenCount
+ * @memberOf module:symbol-tree#
+ * @param {Object} parent
+ * @return {Number}
+ */
+ childrenCount(parent) {
+ const parentNode = this._node(parent);
+
+ if (!parentNode.lastChild) {
+ return 0;
+ }
+
+ return this.index(parentNode.lastChild) + 1;
+ }
+
+ /**
+ * Compare the position of an object relative to another object. A bit set is returned:
+ *
+ * <ul>
+ * <li>DISCONNECTED : 1</li>
+ * <li>PRECEDING : 2</li>
+ * <li>FOLLOWING : 4</li>
+ * <li>CONTAINS : 8</li>
+ * <li>CONTAINED_BY : 16</li>
+ * </ul>
+ *
+ * The semantics are the same as compareDocumentPosition in DOM, with the exception that
+ * DISCONNECTED never occurs with any other bit.
+ *
+ * where `n` and `m` are the amount of ancestors of `left` and `right`;
+ * where `o` is the amount of children of the lowest common ancestor of `left` and `right`:
+ *
+ * * `O(n + m + o)` (worst case)
+ * * `O(n + m)` (amortized, if the tree is not modified)
+ *
+ * @method compareTreePosition
+ * @memberOf module:symbol-tree#
+ * @param {Object} left
+ * @param {Object} right
+ * @return {Number}
+ */
+ compareTreePosition(left, right) {
+ // In DOM terms:
+ // left = reference / context object
+ // right = other
+
+ if (left === right) {
+ return 0;
+ }
+
+ /* jshint -W016 */
+
+ const leftAncestors = []; { // inclusive
+ let leftAncestor = left;
+
+ while (leftAncestor) {
+ if (leftAncestor === right) {
+ return TreePosition.CONTAINS | TreePosition.PRECEDING;
+ // other is ancestor of reference
+ }
+
+ leftAncestors.push(leftAncestor);
+ leftAncestor = this.parent(leftAncestor);
+ }
+ }
+
+
+ const rightAncestors = []; {
+ let rightAncestor = right;
+
+ while (rightAncestor) {
+ if (rightAncestor === left) {
+ return TreePosition.CONTAINED_BY | TreePosition.FOLLOWING;
+ }
+
+ rightAncestors.push(rightAncestor);
+ rightAncestor = this.parent(rightAncestor);
+ }
+ }
+
+
+ const root = reverseArrayIndex(leftAncestors, 0);
+
+ if (!root || root !== reverseArrayIndex(rightAncestors, 0)) {
+ // note: unlike DOM, preceding / following is not set here
+ return TreePosition.DISCONNECTED;
+ }
+
+ // find the lowest common ancestor
+ let commonAncestorIndex = 0;
+ const ancestorsMinLength = Math.min(leftAncestors.length, rightAncestors.length);
+
+ for (let i = 0; i < ancestorsMinLength; ++i) {
+ const leftAncestor = reverseArrayIndex(leftAncestors, i);
+ const rightAncestor = reverseArrayIndex(rightAncestors, i);
+
+ if (leftAncestor !== rightAncestor) {
+ break;
+ }
+
+ commonAncestorIndex = i;
+ }
+
+ // indexes within the common ancestor
+ const leftIndex = this.index(reverseArrayIndex(leftAncestors, commonAncestorIndex + 1));
+ const rightIndex = this.index(reverseArrayIndex(rightAncestors, commonAncestorIndex + 1));
+
+ return rightIndex < leftIndex
+ ? TreePosition.PRECEDING
+ : TreePosition.FOLLOWING;
+ }
+
+ /**
+ * Remove the object from this tree.
+ * Has no effect if already removed.
+ *
+ * * `O(1)`
+ *
+ * @method remove
+ * @memberOf module:symbol-tree#
+ * @param {Object} removeObject
+ * @return {Object} removeObject
+ */
+ remove(removeObject) {
+ const removeNode = this._node(removeObject);
+ const parentNode = this._node(removeNode.parent);
+ const prevNode = this._node(removeNode.previousSibling);
+ const nextNode = this._node(removeNode.nextSibling);
+
+ if (parentNode) {
+ if (parentNode.firstChild === removeObject) {
+ parentNode.firstChild = removeNode.nextSibling;
+ }
+
+ if (parentNode.lastChild === removeObject) {
+ parentNode.lastChild = removeNode.previousSibling;
+ }
+ }
+
+ if (prevNode) {
+ prevNode.nextSibling = removeNode.nextSibling;
+ }
+
+ if (nextNode) {
+ nextNode.previousSibling = removeNode.previousSibling;
+ }
+
+ removeNode.parent = null;
+ removeNode.previousSibling = null;
+ removeNode.nextSibling = null;
+ removeNode.cachedIndex = -1;
+ removeNode.cachedIndexVersion = NaN;
+
+ if (parentNode) {
+ parentNode.childrenChanged();
+ }
+
+ return removeObject;
+ }
+
+ /**
+ * Insert the given object before the reference object.
+ * `newObject` is now the previous sibling of `referenceObject`.
+ *
+ * * `O(1)`
+ *
+ * @method insertBefore
+ * @memberOf module:symbol-tree#
+ * @param {Object} referenceObject
+ * @param {Object} newObject
+ * @throws {Error} If the newObject is already present in this SymbolTree
+ * @return {Object} newObject
+ */
+ insertBefore(referenceObject, newObject) {
+ const referenceNode = this._node(referenceObject);
+ const prevNode = this._node(referenceNode.previousSibling);
+ const newNode = this._node(newObject);
+ const parentNode = this._node(referenceNode.parent);
+
+ if (newNode.isAttached) {
+ throw Error('Given object is already present in this SymbolTree, remove it first');
+ }
+
+ newNode.parent = referenceNode.parent;
+ newNode.previousSibling = referenceNode.previousSibling;
+ newNode.nextSibling = referenceObject;
+ referenceNode.previousSibling = newObject;
+
+ if (prevNode) {
+ prevNode.nextSibling = newObject;
+ }
+
+ if (parentNode && parentNode.firstChild === referenceObject) {
+ parentNode.firstChild = newObject;
+ }
+
+ if (parentNode) {
+ parentNode.childrenChanged();
+ }
+
+ return newObject;
+ }
+
+ /**
+ * Insert the given object after the reference object.
+ * `newObject` is now the next sibling of `referenceObject`.
+ *
+ * * `O(1)`
+ *
+ * @method insertAfter
+ * @memberOf module:symbol-tree#
+ * @param {Object} referenceObject
+ * @param {Object} newObject
+ * @throws {Error} If the newObject is already present in this SymbolTree
+ * @return {Object} newObject
+ */
+ insertAfter(referenceObject, newObject) {
+ const referenceNode = this._node(referenceObject);
+ const nextNode = this._node(referenceNode.nextSibling);
+ const newNode = this._node(newObject);
+ const parentNode = this._node(referenceNode.parent);
+
+ if (newNode.isAttached) {
+ throw Error('Given object is already present in this SymbolTree, remove it first');
+ }
+
+ newNode.parent = referenceNode.parent;
+ newNode.previousSibling = referenceObject;
+ newNode.nextSibling = referenceNode.nextSibling;
+ referenceNode.nextSibling = newObject;
+
+ if (nextNode) {
+ nextNode.previousSibling = newObject;
+ }
+
+ if (parentNode && parentNode.lastChild === referenceObject) {
+ parentNode.lastChild = newObject;
+ }
+
+ if (parentNode) {
+ parentNode.childrenChanged();
+ }
+
+ return newObject;
+ }
+
+ /**
+ * Insert the given object as the first child of the given reference object.
+ * `newObject` is now the first child of `referenceObject`.
+ *
+ * * `O(1)`
+ *
+ * @method prependChild
+ * @memberOf module:symbol-tree#
+ * @param {Object} referenceObject
+ * @param {Object} newObject
+ * @throws {Error} If the newObject is already present in this SymbolTree
+ * @return {Object} newObject
+ */
+ prependChild(referenceObject, newObject) {
+ const referenceNode = this._node(referenceObject);
+ const newNode = this._node(newObject);
+
+ if (newNode.isAttached) {
+ throw Error('Given object is already present in this SymbolTree, remove it first');
+ }
+
+ if (referenceNode.hasChildren) {
+ this.insertBefore(referenceNode.firstChild, newObject);
+ }
+ else {
+ newNode.parent = referenceObject;
+ referenceNode.firstChild = newObject;
+ referenceNode.lastChild = newObject;
+ referenceNode.childrenChanged();
+ }
+
+ return newObject;
+ }
+
+ /**
+ * Insert the given object as the last child of the given reference object.
+ * `newObject` is now the last child of `referenceObject`.
+ *
+ * * `O(1)`
+ *
+ * @method appendChild
+ * @memberOf module:symbol-tree#
+ * @param {Object} referenceObject
+ * @param {Object} newObject
+ * @throws {Error} If the newObject is already present in this SymbolTree
+ * @return {Object} newObject
+ */
+ appendChild(referenceObject, newObject) {
+ const referenceNode = this._node(referenceObject);
+ const newNode = this._node(newObject);
+
+ if (newNode.isAttached) {
+ throw Error('Given object is already present in this SymbolTree, remove it first');
+ }
+
+ if (referenceNode.hasChildren) {
+ this.insertAfter(referenceNode.lastChild, newObject);
+ }
+ else {
+ newNode.parent = referenceObject;
+ referenceNode.firstChild = newObject;
+ referenceNode.lastChild = newObject;
+ referenceNode.childrenChanged();
+ }
+
+ return newObject;
+ }
+}
+
+module.exports = SymbolTree;
+SymbolTree.TreePosition = TreePosition;
diff --git a/school/node_modules/symbol-tree/lib/SymbolTreeNode.js b/school/node_modules/symbol-tree/lib/SymbolTreeNode.js
new file mode 100644
index 0000000..cae7f9a
--- /dev/null
+++ b/school/node_modules/symbol-tree/lib/SymbolTreeNode.js
@@ -0,0 +1,54 @@
+'use strict';
+
+module.exports = class SymbolTreeNode {
+ constructor() {
+ this.parent = null;
+ this.previousSibling = null;
+ this.nextSibling = null;
+
+ this.firstChild = null;
+ this.lastChild = null;
+
+ /** This value is incremented anytime a children is added or removed */
+ this.childrenVersion = 0;
+ /** The last child object which has a cached index */
+ this.childIndexCachedUpTo = null;
+
+ /** This value represents the cached node index, as long as
+ * cachedIndexVersion matches with the childrenVersion of the parent */
+ this.cachedIndex = -1;
+ this.cachedIndexVersion = NaN; // NaN is never equal to anything
+ }
+
+ get isAttached() {
+ return Boolean(this.parent || this.previousSibling || this.nextSibling);
+ }
+
+ get hasChildren() {
+ return Boolean(this.firstChild);
+ }
+
+ childrenChanged() {
+ /* jshint -W016 */
+ // integer wrap around
+ this.childrenVersion = (this.childrenVersion + 1) & 0xFFFFFFFF;
+ this.childIndexCachedUpTo = null;
+ }
+
+ getCachedIndex(parentNode) {
+ // (assumes parentNode is actually the parent)
+ if (this.cachedIndexVersion !== parentNode.childrenVersion) {
+ this.cachedIndexVersion = NaN;
+ // cachedIndex is no longer valid
+ return -1;
+ }
+
+ return this.cachedIndex; // -1 if not cached
+ }
+
+ setCachedIndex(parentNode, index) {
+ // (assumes parentNode is actually the parent)
+ this.cachedIndexVersion = parentNode.childrenVersion;
+ this.cachedIndex = index;
+ }
+};
diff --git a/school/node_modules/symbol-tree/lib/TreeIterator.js b/school/node_modules/symbol-tree/lib/TreeIterator.js
new file mode 100644
index 0000000..f9d6217
--- /dev/null
+++ b/school/node_modules/symbol-tree/lib/TreeIterator.js
@@ -0,0 +1,69 @@
+'use strict';
+
+const TREE = Symbol();
+const ROOT = Symbol();
+const NEXT = Symbol();
+const ITERATE_FUNC = Symbol();
+
+class TreeIterator {
+ constructor(tree, root, firstResult, iterateFunction) {
+ this[TREE] = tree;
+ this[ROOT] = root;
+ this[NEXT] = firstResult;
+ this[ITERATE_FUNC] = iterateFunction;
+ }
+
+ next() {
+ const tree = this[TREE];
+ const iterateFunc = this[ITERATE_FUNC];
+ const root = this[ROOT];
+
+ if (!this[NEXT]) {
+ return {
+ done: true,
+ value: root,
+ };
+ }
+
+ const value = this[NEXT];
+
+ if (iterateFunc === 1) {
+ this[NEXT] = tree._node(value).previousSibling;
+ }
+ else if (iterateFunc === 2) {
+ this[NEXT] = tree._node(value).nextSibling;
+ }
+ else if (iterateFunc === 3) {
+ this[NEXT] = tree._node(value).parent;
+ }
+ else if (iterateFunc === 4) {
+ this[NEXT] = tree.preceding(value, {root: root});
+ }
+ else /* if (iterateFunc === 5)*/ {
+ this[NEXT] = tree.following(value, {root: root});
+ }
+
+ return {
+ done: false,
+ value: value,
+ };
+ }
+}
+
+Object.defineProperty(TreeIterator.prototype, Symbol.iterator, {
+ value: function() {
+ return this;
+ },
+ writable: false,
+});
+
+TreeIterator.PREV = 1;
+TreeIterator.NEXT = 2;
+TreeIterator.PARENT = 3;
+TreeIterator.PRECEDING = 4;
+TreeIterator.FOLLOWING = 5;
+
+Object.freeze(TreeIterator);
+Object.freeze(TreeIterator.prototype);
+
+module.exports = TreeIterator;
diff --git a/school/node_modules/symbol-tree/lib/TreePosition.js b/school/node_modules/symbol-tree/lib/TreePosition.js
new file mode 100644
index 0000000..fd2b6ed
--- /dev/null
+++ b/school/node_modules/symbol-tree/lib/TreePosition.js
@@ -0,0 +1,11 @@
+'use strict';
+
+/* eslint-disable sort-keys */
+module.exports = Object.freeze({
+ // same as DOM DOCUMENT_POSITION_
+ DISCONNECTED: 1,
+ PRECEDING: 2,
+ FOLLOWING: 4,
+ CONTAINS: 8,
+ CONTAINED_BY: 16,
+});
diff --git a/school/node_modules/symbol-tree/package.json b/school/node_modules/symbol-tree/package.json
new file mode 100644
index 0000000..dfaefdd
--- /dev/null
+++ b/school/node_modules/symbol-tree/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "symbol-tree",
+ "version": "3.2.4",
+ "description": "Turn any collection of objects into its own efficient tree or linked list using Symbol",
+ "main": "lib/SymbolTree.js",
+ "scripts": {
+ "lint": "eslint lib test",
+ "test": "istanbul cover test/SymbolTree.js",
+ "posttest": "npm run lint",
+ "ci": "istanbul cover test/SymbolTree.js --report lcovonly && cat ./coverage/lcov.info | coveralls",
+ "postci": "npm run posttest",
+ "predocumentation": "cp readme-header.md README.md",
+ "documentation": "jsdoc2md --files lib/SymbolTree.js >> README.md"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jsdom/js-symbol-tree.git"
+ },
+ "keywords": [
+ "list",
+ "queue",
+ "stack",
+ "linked-list",
+ "tree",
+ "es6",
+ "dom",
+ "symbol"
+ ],
+ "files": [
+ "lib"
+ ],
+ "author": "Joris van der Wel <joris@jorisvanderwel.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/jsdom/js-symbol-tree/issues"
+ },
+ "homepage": "https://github.com/jsdom/js-symbol-tree#symbol-tree",
+ "devDependencies": {
+ "babel-eslint": "^10.0.1",
+ "coveralls": "^3.0.0",
+ "eslint": "^5.16.0",
+ "eslint-plugin-import": "^2.2.0",
+ "istanbul": "^0.4.5",
+ "jsdoc-to-markdown": "^5.0.0",
+ "tape": "^4.0.0"
+ }
+}