@types/symbol-tree
- Version 3.2.5
- Published
- 13.3 kB
- No dependencies
- MIT license
Install
npm i @types/symbol-tree
yarn add @types/symbol-tree
pnpm add @types/symbol-tree
Overview
TypeScript definitions for symbol-tree
Index
Classes
SymbolTree
- ancestorsIterator()
- ancestorsToArray()
- appendChild()
- childrenCount()
- childrenIterator()
- childrenToArray()
- compareTreePosition()
- firstChild()
- following()
- hasChildren()
- index()
- initialize()
- insertAfter()
- insertBefore()
- lastChild()
- lastInclusiveDescendant()
- nextSibling()
- nextSiblingsIterator()
- parent()
- preceding()
- prependChild()
- previousSibling()
- previousSiblingsIterator()
- remove()
- treeIterator()
- TreePosition
- treeToArray()
Interfaces
Classes
class SymbolTree
class SymbolTree<T extends object = any> {}
constructor
constructor(description?: string);
Parameter description
Description used for the Symbol
**Default:**
'SymbolTree data'
property TreePosition
static readonly TreePosition: typeof TreePosition;
method ancestorsIterator
ancestorsIterator: (object: T) => TreeIterator<T>;
Iterate over all inclusive ancestors of the given object
*
O(1)
for a single iterationAn iterable iterator (ES6)
method ancestorsToArray
ancestorsToArray: { <THIS>( object: T, options?: SymbolTree.ToArrayOptions<T> & { thisArg: THIS; filter(this: THIS, object: T): any; } ): T[]; (object: T, options?: SymbolTree.ToArrayOptions<T>): T[];};
Append all inclusive ancestors of the given object to an array.
*
O(n)
wheren
is the amount of ancestors of the givenobject
method appendChild
appendChild: <U extends T>(referenceObject: T, newObject: U) => U;
Insert the given object as the last child of the given reference object.
newObject
is now the last child ofreferenceObject
.*
O(1)
Throws
{Error} If the newObject is already present in this SymbolTree
method childrenCount
childrenCount: (object: T) => number;
Calculate the number of children.
*
O(n)
wheren
is the amount of children *O(1)
(amortized, if the tree is not modified)
method childrenIterator
childrenIterator: ( parent: T, options?: SymbolTree.IteratorOptions) => TreeIterator<T>;
Iterate over all children of the given object
*
O(1)
for a single iterationAn iterable iterator (ES6)
method childrenToArray
childrenToArray: { <THIS>( parent: T, options?: SymbolTree.ToArrayOptions<T> & { thisArg: THIS; filter(this: THIS, object: T): any; } ): T[]; (parent: T, options?: SymbolTree.ToArrayOptions<T>): T[];};
Append all children of the given object to an array.
*
O(n)
wheren
is the amount of children of the givenparent
method compareTreePosition
compareTreePosition: (left: T, right: T) => number;
Compare the position of an object relative to another object. A bit set is returned:
DISCONNECTED : 1 PRECEDING : 2 FOLLOWING : 4 CONTAINS : 8 CONTAINED_BY : 16
The semantics are the same as compareDocumentPosition in DOM, with the exception that DISCONNECTED never occurs with any other bit.
where
n
andm
are the amount of ancestors ofleft
andright
; whereo
is the amount of children of the lowest common ancestor ofleft
andright
:*
O(n + m + o)
(worst case) *O(n + m)
(amortized, if the tree is not modified)
method firstChild
firstChild: (object: T) => T | null;
Returns the first child of the given object.
*
O(1)
method following
following: (object: T, options?: SymbolTree.SiblingOptions<T>) => T | null;
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) wheren
is the amount of objects in the entire tree *O(1)
(amortized when walking the entire tree)
method hasChildren
hasChildren: (object: T) => boolean;
Returns
true
if the object has any children. Otherwise it returnsfalse
.*
O(1)
method index
index: (object: T) => number;
Find the index of the given object (the number of preceding siblings).
*
O(n)
wheren
is the amount of preceding siblings *O(1)
(amortized, if the tree is not modified)The number of preceding siblings, or -1 if the object has no parent
method initialize
initialize: <O extends T>(object: O) => O;
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 insertAfter
insertAfter: <U extends T>(referenceObject: T, newObject: U) => U;
Insert the given object after the reference object.
newObject
is now the next sibling ofreferenceObject
.*
O(1)
Throws
{Error} If the newObject is already present in this SymbolTree
method insertBefore
insertBefore: <U extends T>(referenceObject: T, newObject: U) => U;
Insert the given object before the reference object.
newObject
is now the previous sibling ofreferenceObject
.*
O(1)
Throws
{Error} If the newObject is already present in this SymbolTree
method lastChild
lastChild: (object: T) => T | null;
Returns the last child of the given object.
*
O(1)
method lastInclusiveDescendant
lastInclusiveDescendant: (object: T) => T | null;
Find the inclusive descendant that is last in tree order of the given object.
*
O(n)
(worst case) wheren
is the depth of the subtree ofobject
method nextSibling
nextSibling: (object: T) => T | null;
Returns the next sibling of the given object.
*
O(1)
method nextSiblingsIterator
nextSiblingsIterator: (object: T) => TreeIterator<T>;
Iterate over all the next siblings of the given object. (in tree order)
*
O(1)
for a single iterationAn iterable iterator (ES6)
method parent
parent: (object: T) => T | null;
Return the parent of the given object.
*
O(1)
method preceding
preceding: (object: T, options?: SymbolTree.SiblingOptions<T>) => T | null;
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 prependChild
prependChild: <U extends T>(referenceObject: T, newObject: U) => U;
Insert the given object as the first child of the given reference object.
newObject
is now the first child ofreferenceObject
.*
O(1)
Throws
{Error} If the newObject is already present in this SymbolTree
method previousSibling
previousSibling: (object: T) => T | null;
Returns the previous sibling of the given object.
*
O(1)
method previousSiblingsIterator
previousSiblingsIterator: (object: T) => TreeIterator<T>;
Iterate over all the previous siblings of the given object. (in reverse tree order)
*
O(1)
for a single iterationAn iterable iterator (ES6)
method remove
remove: <U extends T>(object: U) => U;
Remove the object from this tree. Has no effect if already removed.
*
O(1)
method treeIterator
treeIterator: ( object: T, options?: SymbolTree.IteratorOptions) => TreeIterator<T>;
Iterate over all descendants of the given object (in tree order).
Where
n
is the amount of objects in the sub-tree of the givenroot
:*
O(n)
(worst case for a single iteration) *O(n)
(amortized, when completing the iterator)An iterable iterator (ES6)
method treeToArray
treeToArray: { <THIS>( object: T, options?: SymbolTree.ToArrayOptions<T> & { thisArg: THIS; filter(this: THIS, object: T): any; } ): T[]; (object: T, options?: SymbolTree.ToArrayOptions<T>): T[];};
Append all descendants of the given object to an array (in tree order).
*
O(n)
wheren
is the amount of objects in the sub-tree of the givenobject
Interfaces
interface IteratorOptions
interface IteratorOptions {}
property reverse
reverse?: boolean | undefined;
Whether to iterate in reverse tree order.
false
interface SiblingOptions
interface SiblingOptions<T extends object = any> {}
property root
root?: T | null | undefined;
Used to constrain the operation to a subtree.
When
null
, the whole tree is walked to the real root.null
property skipChildren
skipChildren?: boolean | undefined;
If set, ignore the children of
object
false
interface ToArrayOptions
interface ToArrayOptions<T extends object = any> {}
property array
array?: T[] | undefined;
The array to initialize the operation with.
new Array(0);
property thisArg
thisArg?: any;
Value to use as
this
when executingfilter
.
method filter
filter: (object: T) => any;
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.Parameter object
Package Files (2)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/symbol-tree
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/symbol-tree)
- HTML<a href="https://www.jsdocs.io/package/@types/symbol-tree"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2822 ms. - Missing or incorrect documentation? Open an issue for this package.