$
This commit is contained in:
838
node_modules/symbol-tree/lib/SymbolTree.js
generated
vendored
Normal file
838
node_modules/symbol-tree/lib/SymbolTree.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
54
node_modules/symbol-tree/lib/SymbolTreeNode.js
generated
vendored
Normal file
54
node_modules/symbol-tree/lib/SymbolTreeNode.js
generated
vendored
Normal file
@@ -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;
|
||||
}
|
||||
};
|
||||
69
node_modules/symbol-tree/lib/TreeIterator.js
generated
vendored
Normal file
69
node_modules/symbol-tree/lib/TreeIterator.js
generated
vendored
Normal file
@@ -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;
|
||||
11
node_modules/symbol-tree/lib/TreePosition.js
generated
vendored
Normal file
11
node_modules/symbol-tree/lib/TreePosition.js
generated
vendored
Normal file
@@ -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,
|
||||
});
|
||||
Reference in New Issue
Block a user