Skip to content

Commit cec9cb7

Browse files
Improve jsdoc
1 parent dc41bb2 commit cec9cb7

File tree

1 file changed

+64
-16
lines changed

1 file changed

+64
-16
lines changed

lib/SymbolTree.js

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
'use strict';
22

3-
const SymbolTreeNode = require('./SymbolTreeNode');
4-
53
/**
64
* @module symbol-tree
75
* @author Joris van der Wel <joris@jorisvanderwel.com>
86
*/
97

10-
/**
11-
* @param [description='SymbolTree data'] Description used for the Symbol
12-
* @constructor
13-
* @alias module:symbol-tree
14-
*/
15-
module.exports = class SymbolTree {
8+
const SymbolTreeNode = require('./SymbolTreeNode');
9+
10+
class SymbolTree {
11+
12+
/**
13+
* @constructor
14+
* @alias module:symbol-tree
15+
* @param [description='SymbolTree data'] Description used for the Symbol
16+
*/
1617
constructor(description) {
1718
this.symbol = Symbol(description || 'SymbolTree data');
1819
}
1920

2021
/**
2122
* You can optionally initialize an object after its creation,
22-
* to take advantage of V8's fast properties
23-
* @method initialize
23+
* to take advantage of V8's fast properties. Also useful if you would like to
24+
* freeze your object.
25+
*
26+
* `O(1)`
27+
*
28+
* @method
29+
* @alias module:symbol-tree#initialize
2430
* @param {Object} object
2531
* @return {Object} object
2632
*/
@@ -46,8 +52,11 @@ module.exports = class SymbolTree {
4652

4753
/**
4854
* Returns true if the object has any children.
55+
*
4956
* `O(1)`
57+
*
5058
* @method isEmpty
59+
* @memberOf module:symbol-tree#
5160
* @param {Object} object
5261
* @return {Boolean}
5362
*/
@@ -57,8 +66,11 @@ module.exports = class SymbolTree {
5766

5867
/**
5968
* Return the first child of the given object.
69+
*
6070
* `O(1)`
71+
*
6172
* @method first
73+
* @memberOf module:symbol-tree#
6274
* @param {Object} object
6375
* @return {Object}
6476
*/
@@ -68,8 +80,11 @@ module.exports = class SymbolTree {
6880

6981
/**
7082
* Return the last child of the given object.
83+
*
7184
* `O(1)`
85+
*
7286
* @method last
87+
* @memberOf module:symbol-tree#
7388
* @param {Object} object
7489
* @return {Object}
7590
*/
@@ -79,8 +94,11 @@ module.exports = class SymbolTree {
7994

8095
/**
8196
* Return the previous sibling of the given object.
97+
*
8298
* `O(1)`
99+
*
83100
* @method prev
101+
* @memberOf module:symbol-tree#
84102
* @param {Object} object
85103
* @return {Object}
86104
*/
@@ -90,8 +108,11 @@ module.exports = class SymbolTree {
90108

91109
/**
92110
* Return the next sibling of the given object.
111+
*
93112
* `O(1)`
113+
*
94114
* @method next
115+
* @memberOf module:symbol-tree#
95116
* @param {Object} object
96117
* @return {Object}
97118
*/
@@ -101,8 +122,11 @@ module.exports = class SymbolTree {
101122

102123
/**
103124
* Return the parent of the given object.
125+
*
104126
* `O(1)`
127+
*
105128
* @method parent
129+
* @memberOf module:symbol-tree#
106130
* @param {Object} object
107131
* @return {Object}
108132
*/
@@ -116,6 +140,7 @@ module.exports = class SymbolTree {
116140
* `O(n)` (worst case)
117141
*
118142
* @method lastInclusiveDescendant
143+
* @memberOf module:symbol-tree#
119144
* @param {Object} object
120145
* @return {Object}
121146
*/
@@ -128,10 +153,16 @@ module.exports = class SymbolTree {
128153

129154
return object;
130155
}
156+
157+
/**
131158
* Find the preceding object (A) of the given object (B).
132159
* An object A is preceding an object B if A and B are in the same tree
133160
* and A comes before B in tree order.
161+
*
162+
* `O(n)` (worst case)
163+
*
134164
* @method preceding
165+
* @memberOf module:symbol-tree#
135166
* @param {Object} object
136167
* @param {Object} [treeRoot] If set, `treeRoot` must be an inclusive ancestor
137168
* of the return value (or else null is returned). This check _assumes_
@@ -157,7 +188,11 @@ module.exports = class SymbolTree {
157188
* Find the following object (A) of the given object (B).
158189
* An object A is following an object B if A and B are in the same tree
159190
* and A comes after B in tree order.
191+
*
192+
* `O(n)` (worst case)
193+
*
160194
* @method following
195+
* @memberOf module:symbol-tree#
161196
* @param {!Object} object
162197
* @param {Object} [treeRoot] If set, `treeRoot` must be an inclusive ancestor
163198
* of the return value (or else null is returned). This check _assumes_
@@ -194,9 +229,12 @@ module.exports = class SymbolTree {
194229

195230
/**
196231
* Remove the object from this tree.
197-
* `O(1)`
198232
* Has no effect if already removed.
233+
*
234+
* `O(1)`
235+
*
199236
* @method remove
237+
* @memberOf module:symbol-tree#
200238
* @param {Object} removeObject
201239
* @return {Object} removeObject
202240
*/
@@ -233,10 +271,12 @@ module.exports = class SymbolTree {
233271

234272
/**
235273
* Insert the given object before the reference object.
274+
* `newObject` is now the previous sibling of `referenceObject`.
275+
*
236276
* `O(1)`
237-
* `newObject` is now the previous sibling of `referenceObject`
238277
*
239278
* @method insertBefore
279+
* @memberOf module:symbol-tree#
240280
* @param {Object} newObject
241281
* @param {Object} referenceObject
242282
* @throws {Error} If the newObject is already present in this SymbolTree
@@ -270,10 +310,12 @@ module.exports = class SymbolTree {
270310

271311
/**
272312
* Insert the given object after the reference object.
313+
* `newObject` is now the next sibling of `referenceObject`.
314+
*
273315
* `O(1)`
274-
* `newObject` is now the next sibling of `referenceObject`
275316
*
276317
* @method insertAfter
318+
* @memberOf module:symbol-tree#
277319
* @param {Object} newObject
278320
* @param {Object} referenceObject
279321
* @throws {Error} If the newObject is already present in this SymbolTree
@@ -307,10 +349,12 @@ module.exports = class SymbolTree {
307349

308350
/**
309351
* Insert the given object as the first child of the given reference object.
352+
* `newObject` is now the first child of `referenceObject`.
353+
*
310354
* `O(1)`
311-
* `newObject` is now the first child of `referenceObject`
312355
*
313356
* @method insertFirst
357+
* @memberOf module:symbol-tree#
314358
* @param {Object} newObject
315359
* @param {Object} referenceObject
316360
* @throws {Error} If the newObject is already present in this SymbolTree
@@ -338,10 +382,12 @@ module.exports = class SymbolTree {
338382

339383
/**
340384
* Insert the given object as the last child of the given reference object.
385+
* `newObject` is now the last child of `referenceObject`.
386+
*
341387
* `O(1)`
342-
* `newObject` is now the last child of `referenceObject`
343388
*
344389
* @method insertLast
390+
* @memberOf module:symbol-tree#
345391
* @param {Object} newObject
346392
* @param {Object} referenceObject
347393
* @throws {Error} If the newObject is already present in this SymbolTree
@@ -366,4 +412,6 @@ module.exports = class SymbolTree {
366412

367413
return newObject;
368414
}
369-
};
415+
}
416+
417+
module.exports = SymbolTree;

0 commit comments

Comments
 (0)