{
"_args": [
[
{
"raw": "symbol-tree@^3.2.2",
"scope": null,
"escapedName": "symbol-tree",
"name": "symbol-tree",
"rawSpec": "^3.2.2",
"spec": ">=3.2.2 <4.0.0",
"type": "range"
},
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/jsdom"
]
],
"_from": "symbol-tree@>=3.2.2 <4.0.0",
"_id": "symbol-tree@3.2.2",
"_inCache": true,
"_location": "/symbol-tree",
"_nodeVersion": "7.2.1",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/symbol-tree-3.2.2.tgz_1486847058094_0.6699730809777975"
},
"_npmUser": {
"name": "joris-van-der-wel",
"email": "joris@jorisvanderwel.com"
},
"_npmVersion": "3.10.10",
"_phantomChildren": {},
"_requested": {
"raw": "symbol-tree@^3.2.2",
"scope": null,
"escapedName": "symbol-tree",
"name": "symbol-tree",
"rawSpec": "^3.2.2",
"spec": ">=3.2.2 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
"_shasum": "ae27db38f660a7ae2e1c3b7d1bc290819b8519e6",
"_shrinkwrap": null,
"_spec": "symbol-tree@^3.2.2",
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/jsdom",
"author": {
"name": "Joris van der Wel",
"email": "joris@jorisvanderwel.com"
},
"bugs": {
"url": "https://github.com/jsdom/js-symbol-tree/issues"
},
"dependencies": {},
"description": "Turn any collection of objects into its own efficient tree or linked list using Symbol",
"devDependencies": {
"babel-eslint": "^7.1.1",
"coveralls": "^2.11.15",
"eslint": "^3.12.0",
"eslint-plugin-import": "^2.2.0",
"istanbul": "^0.4.5",
"jsdoc-to-markdown": "^3.0.0",
"tape": "^4.0.0"
},
"directories": {},
"dist": {
"shasum": "ae27db38f660a7ae2e1c3b7d1bc290819b8519e6",
"tarball": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz"
},
"files": [
"lib",
"api.md"
],
"gitHead": "1e213a3f820f79c083859cce601ed091154449b5",
"homepage": "https://github.com/jsdom/js-symbol-tree#symbol-tree",
"keywords": [
"list",
"queue",
"stack",
"linked-list",
"tree",
"es6",
"dom",
"symbol"
],
"license": "MIT",
"main": "lib/SymbolTree.js",
"maintainers": [
{
"name": "joris-van-der-wel",
"email": "joris@jorisvanderwel.com"
}
],
"name": "symbol-tree",
"optionalDependencies": {},
"readme": "symbol-tree\n===========\n[![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)\n\nTurn any collection of objects into its own efficient tree or linked list using `Symbol`.\n\nThis 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.\n\nNode.js 4+, io.js and modern browsers are supported.\n\nExample\n-------\nA linked list:\n\n```javascript\nconst SymbolTree = require('symbol-tree');\nconst tree = new SymbolTree();\n\nlet a = {foo: 'bar'}; // or `new Whatever()`\nlet b = {foo: 'baz'};\nlet c = {foo: 'qux'};\n\ntree.insertBefore(b, a); // insert a before b\ntree.insertAfter(b, c); // insert c after b\n\nconsole.log(tree.nextSibling(a) === b);\nconsole.log(tree.nextSibling(b) === c);\nconsole.log(tree.previousSibling(c) === b);\n\ntree.remove(b);\nconsole.log(tree.nextSibling(a) === c);\n```\n\nA tree:\n\n```javascript\nconst SymbolTree = require('symbol-tree');\nconst tree = new SymbolTree();\n\nlet parent = {};\nlet a = {};\nlet b = {};\nlet c = {};\n\ntree.prependChild(parent, a); // insert a as the first child\ntree.appendChild(parent,c ); // insert c as the last child\ntree.insertAfter(a, b); // insert b after a, it now has the same parent as a\n\nconsole.log(tree.firstChild(parent) === a);\nconsole.log(tree.nextSibling(tree.firstChild(parent)) === b);\nconsole.log(tree.lastChild(parent) === c);\n\nlet grandparent = {};\ntree.prependChild(grandparent, parent);\nconsole.log(tree.firstChild(tree.firstChild(grandparent)) === a);\n```\n\nTesting\n-------\nMake sure you install the dependencies first:\n\n npm install\n\nYou can now run the unit tests by executing:\n\n npm test\n\nThe line and branch coverage should be 100%.\n\nAPI Documentation\n-----------------\n\n\n## symbol-tree\n**Author:** Joris van der Wel \n\n* [symbol-tree](#module_symbol-tree)\n * [SymbolTree](#exp_module_symbol-tree--SymbolTree) ⏏\n * [new SymbolTree([description])](#new_module_symbol-tree--SymbolTree_new)\n * [.initialize(object)](#module_symbol-tree--SymbolTree+initialize) ⇒ Object
\n * [.hasChildren(object)](#module_symbol-tree--SymbolTree+hasChildren) ⇒ Boolean
\n * [.firstChild(object)](#module_symbol-tree--SymbolTree+firstChild) ⇒ Object
\n * [.lastChild(object)](#module_symbol-tree--SymbolTree+lastChild) ⇒ Object
\n * [.previousSibling(object)](#module_symbol-tree--SymbolTree+previousSibling) ⇒ Object
\n * [.nextSibling(object)](#module_symbol-tree--SymbolTree+nextSibling) ⇒ Object
\n * [.parent(object)](#module_symbol-tree--SymbolTree+parent) ⇒ Object
\n * [.lastInclusiveDescendant(object)](#module_symbol-tree--SymbolTree+lastInclusiveDescendant) ⇒ Object
\n * [.preceding(object, [options])](#module_symbol-tree--SymbolTree+preceding) ⇒ Object
\n * [.following(object, [options])](#module_symbol-tree--SymbolTree+following) ⇒ Object
\n * [.childrenToArray(parent, [options])](#module_symbol-tree--SymbolTree+childrenToArray) ⇒ Array.<Object>
\n * [.ancestorsToArray(object, [options])](#module_symbol-tree--SymbolTree+ancestorsToArray) ⇒ Array.<Object>
\n * [.treeToArray(root, [options])](#module_symbol-tree--SymbolTree+treeToArray) ⇒ Array.<Object>
\n * [.childrenIterator(parent, [options])](#module_symbol-tree--SymbolTree+childrenIterator) ⇒ Object
\n * [.previousSiblingsIterator(object)](#module_symbol-tree--SymbolTree+previousSiblingsIterator) ⇒ Object
\n * [.nextSiblingsIterator(object)](#module_symbol-tree--SymbolTree+nextSiblingsIterator) ⇒ Object
\n * [.ancestorsIterator(object)](#module_symbol-tree--SymbolTree+ancestorsIterator) ⇒ Object
\n * [.treeIterator(root, options)](#module_symbol-tree--SymbolTree+treeIterator) ⇒ Object
\n * [.index(child)](#module_symbol-tree--SymbolTree+index) ⇒ Number
\n * [.childrenCount(parent)](#module_symbol-tree--SymbolTree+childrenCount) ⇒ Number
\n * [.compareTreePosition(left, right)](#module_symbol-tree--SymbolTree+compareTreePosition) ⇒ Number
\n * [.remove(removeObject)](#module_symbol-tree--SymbolTree+remove) ⇒ Object
\n * [.insertBefore(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertBefore) ⇒ Object
\n * [.insertAfter(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertAfter) ⇒ Object
\n * [.prependChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+prependChild) ⇒ Object
\n * [.appendChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+appendChild) ⇒ Object
\n\n\n\n### SymbolTree ⏏\n**Kind**: Exported class\n\n\n#### new SymbolTree([description])\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| [description] | string
| "'SymbolTree data'"
| Description used for the Symbol |\n\n\n\n#### symbolTree.initialize(object) ⇒ Object
\nYou can use this function to (optionally) initialize an object right after its creation,\nto take advantage of V8's fast properties. Also useful if you would like to\nfreeze your object.\n\n`O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- object\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.hasChildren(object) ⇒ Boolean
\nReturns `true` if the object has any children. Otherwise it returns `false`.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.firstChild(object) ⇒ Object
\nReturns the first child of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.lastChild(object) ⇒ Object
\nReturns the last child of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.previousSibling(object) ⇒ Object
\nReturns the previous sibling of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.nextSibling(object) ⇒ Object
\nReturns the next sibling of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.parent(object) ⇒ Object
\nReturn the parent of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.lastInclusiveDescendant(object) ⇒ Object
\nFind 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.preceding(object, [options]) ⇒ Object
\nFind the preceding object (A) of the given object (B).\nAn object A is preceding an object B if A and B are in the same tree\nand A comes before B in tree order.\n\n* `O(n)` (worst case)\n* `O(1)` (amortized when walking the entire tree)\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type | Description |\n| --- | --- | --- |\n| object | Object
| |\n| [options] | Object
| |\n| [options.root] | Object
| 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` |\n\n\n\n#### symbolTree.following(object, [options]) ⇒ Object
\nFind the following object (A) of the given object (B).\nAn object A is following an object B if A and B are in the same tree\nand 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| object | Object
| | |\n| [options] | Object
| | |\n| [options.root] | Object
| | 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` |\n| [options.skipChildren] | Boolean
| false
| If set, ignore the children of `object` |\n\n\n\n#### symbolTree.childrenToArray(parent, [options]) ⇒ Array.<Object>
\nAppend 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| parent | Object
| | |\n| [options] | Object
| | |\n| [options.array] | Array.<Object>
| []
| |\n| [options.filter] | function
| | 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. |\n| [options.thisArg] | \\*
| | Value to use as `this` when executing `filter`. |\n\n\n\n#### symbolTree.ancestorsToArray(object, [options]) ⇒ Array.<Object>
\nAppend 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| object | Object
| | |\n| [options] | Object
| | |\n| [options.array] | Array.<Object>
| []
| |\n| [options.filter] | function
| | 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. |\n| [options.thisArg] | \\*
| | Value to use as `this` when executing `filter`. |\n\n\n\n#### symbolTree.treeToArray(root, [options]) ⇒ Array.<Object>
\nAppend 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| root | Object
| | |\n| [options] | Object
| | |\n| [options.array] | Array.<Object>
| []
| |\n| [options.filter] | function
| | 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. |\n| [options.thisArg] | \\*
| | Value to use as `this` when executing `filter`. |\n\n\n\n#### symbolTree.childrenIterator(parent, [options]) ⇒ Object
\nIterate over all children of the given object\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- An iterable iterator (ES6)\n\n| Param | Type | Default |\n| --- | --- | --- |\n| parent | Object
| |\n| [options] | Object
| |\n| [options.reverse] | Boolean
| false
|\n\n\n\n#### symbolTree.previousSiblingsIterator(object) ⇒ Object
\nIterate over all the previous siblings of the given object. (in reverse tree order)\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- An iterable iterator (ES6)\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.nextSiblingsIterator(object) ⇒ Object
\nIterate over all the next siblings of the given object. (in tree order)\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- An iterable iterator (ES6)\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.ancestorsIterator(object) ⇒ Object
\nIterate over all inclusive ancestors of the given object\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- An iterable iterator (ES6)\n\n| Param | Type |\n| --- | --- |\n| object | Object
|\n\n\n\n#### symbolTree.treeIterator(root, options) ⇒ Object
\nIterate over all descendants of the given object (in tree order).\n\nWhere `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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- An iterable iterator (ES6)\n\n| Param | Type | Default |\n| --- | --- | --- |\n| root | Object
| |\n| options | Object
| |\n| [options.reverse] | Boolean
| false
|\n\n\n\n#### symbolTree.index(child) ⇒ Number
\nFind 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Number
- The number of preceding siblings, or -1 if the object has no parent\n\n| Param | Type |\n| --- | --- |\n| child | Object
|\n\n\n\n#### symbolTree.childrenCount(parent) ⇒ Number
\nCalculate 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| parent | Object
|\n\n\n\n#### symbolTree.compareTreePosition(left, right) ⇒ Number
\nCompare the position of an object relative to another object. A bit set is returned:\n\n\n - DISCONNECTED : 1
\n - PRECEDING : 2
\n - FOLLOWING : 4
\n - CONTAINS : 8
\n - CONTAINED_BY : 16
\n
\n\nThe semantics are the same as compareDocumentPosition in DOM, with the exception that\nDISCONNECTED never occurs with any other bit.\n\nwhere `n` and `m` are the amount of ancestors of `left` and `right`;\nwhere `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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n\n| Param | Type |\n| --- | --- |\n| left | Object
|\n| right | Object
|\n\n\n\n#### symbolTree.remove(removeObject) ⇒ Object
\nRemove the object from this tree.\nHas no effect if already removed.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- removeObject\n\n| Param | Type |\n| --- | --- |\n| removeObject | Object
|\n\n\n\n#### symbolTree.insertBefore(referenceObject, newObject) ⇒ Object
\nInsert the given object before the reference object.\n`newObject` is now the previous sibling of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- newObject\n**Throws**:\n\n- Error
If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | Object
|\n| newObject | Object
|\n\n\n\n#### symbolTree.insertAfter(referenceObject, newObject) ⇒ Object
\nInsert the given object after the reference object.\n`newObject` is now the next sibling of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- newObject\n**Throws**:\n\n- Error
If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | Object
|\n| newObject | Object
|\n\n\n\n#### symbolTree.prependChild(referenceObject, newObject) ⇒ Object
\nInsert 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- newObject\n**Throws**:\n\n- Error
If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | Object
|\n| newObject | Object
|\n\n\n\n#### symbolTree.appendChild(referenceObject, newObject) ⇒ Object
\nInsert 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**Kind**: instance method of [SymbolTree](#exp_module_symbol-tree--SymbolTree)
\n**Returns**: Object
- newObject\n**Throws**:\n\n- Error
If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | Object
|\n| newObject | Object
|\n\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/jsdom/js-symbol-tree.git"
},
"scripts": {
"ci": "istanbul cover test/SymbolTree.js --report lcovonly && cat ./coverage/lcov.info | coveralls",
"documentation": "jsdoc2md --files lib/SymbolTree.js >> README.md",
"lint": "eslint lib test",
"postci": "npm run posttest",
"posttest": "npm run lint",
"predocumentation": "cp readme-header.md README.md",
"test": "istanbul cover test/SymbolTree.js"
},
"version": "3.2.2"
}