@@ -7,10 +7,9 @@ const configurable = true,
77 /**
88 * Creates an array of node objects with parent and siblings
99 *
10- * @param {unObject[] } siblings - Array of sibling nodes
11- * @param {unObject } [parent] - Parent node
12- * @returns {{ node: unObject; parent: unObject; siblings: unObject }[] }
13- * Array of objects containing node, parent, and siblings
10+ * @param siblings - Array of sibling nodes
11+ * @param [parent] - Parent node
12+ * @returns Array of objects containing node, parent, and siblings
1413 */
1514 getItems = ( siblings : unObject [ ] , parent ?: unObject ) =>
1615 [ ...siblings ] . reverse ( ) . map ( ( node ) => ( { node, parent, siblings } ) ) ;
@@ -19,23 +18,19 @@ const configurable = true,
1918 * Creates a flat representation of a JSON tree with helper functions to
2019 * manipulate the tree
2120 *
22- * @param {unObject[] } tree - The tree structure to flatten
23- * @param {object } [root0] - Configuration object for key names
24- * @param {string } [root0.branch] - Key name for branch property (default:
25- * "branch")
26- * @param {string } [root0.children] - Key name for children property (default:
21+ * @param tree - The tree structure to flatten
22+ * @param [root0] - Configuration object for key names
23+ * @param [root0.branch] - Key name for branch property (default: "branch")
24+ * @param [root0.children] - Key name for children property (default:
2725 * "children")
28- * @param {string } [root0.id] - Key name for id property (default: "id")
29- * @param {string } [root0.index] - Key name for index property (default:
30- * "index")
31- * @param {string } [root0.next] - Key name for next property (default: "next")
32- * @param {string } [root0.parent] - Key name for parent property (default:
33- * "parent")
34- * @param {string } [root0.prev] - Key name for prev property (default: "prev")
35- * @param {string } [root0.siblings] - Key name for siblings property (default:
26+ * @param [root0.id] - Key name for id property (default: "id")
27+ * @param [root0.index] - Key name for index property (default: "index")
28+ * @param [root0.next] - Key name for next property (default: "next")
29+ * @param [root0.parent] - Key name for parent property (default: "parent")
30+ * @param [root0.prev] - Key name for prev property (default: "prev")
31+ * @param [root0.siblings] - Key name for siblings property (default:
3632 * "siblings")
37- * @returns {object } Object containing nodes, nodesMap and manipulation
38- * functions
33+ * @returns Object containing nodes, nodesMap and manipulation functions
3934 */
4035export default (
4136 tree : unObject [ ] ,
@@ -55,7 +50,7 @@ export default (
5550 /**
5651 * Gets the branch (path from root) for the current node
5752 *
58- * @returns { unObject[] } Array of nodes from root to current node
53+ * @returns Array of nodes from root to current node
5954 */
6055 get ( this : unObject ) : unObject [ ] {
6156 const ret = [ this ] ;
@@ -67,7 +62,7 @@ export default (
6762 /**
6863 * Gets the index of the current node in its siblings array
6964 *
70- * @returns { number } Index of the node in its siblings array
65+ * @returns Index of the node in its siblings array
7166 */
7267 get ( this : unObject ) : number {
7368 return ( this [ keySiblings ] as unObject [ ] ) . findIndex (
@@ -79,7 +74,7 @@ export default (
7974 /**
8075 * Gets the next sibling node
8176 *
82- * @returns { undefined | unObject } Next sibling node or undefined if none
77+ * @returns Next sibling node or undefined if none
8378 */
8479 get ( this : unObject ) : undefined | unObject {
8580 return ( this [ keySiblings ] as unObject [ ] ) [
@@ -91,8 +86,7 @@ export default (
9186 /**
9287 * Gets the previous sibling node
9388 *
94- * @returns {undefined | unObject } Previous sibling node or undefined if
95- * none
89+ * @returns Previous sibling node or undefined if none
9690 */
9791 get ( this : unObject ) : undefined | unObject {
9892 return ( this [ keySiblings ] as unObject [ ] ) [
@@ -104,9 +98,9 @@ export default (
10498 /**
10599 * Generator function that traverses the tree and yields each node
106100 *
107- * @param { unObject[] } nodes - Array of nodes to traverse
101+ * @param nodes - Array of nodes to traverse
108102 * @yields {unObject} Each node in the tree
109- * @returns { Generator<unObject> } Generator that yields nodes
103+ * @returns Generator that yields nodes
110104 */
111105 const getNodes = function * ( nodes : unObject [ ] ) {
112106 const stack = getItems ( nodes ) ;
@@ -143,10 +137,10 @@ export default (
143137 /**
144138 * Function to run actions on nodes
145139 *
146- * @param { string } pId - ID of the node to perform action on
147- * @param { string } action - Action to perform (add, addChild, remove, up,
148- * down, left, right)
149- * @returns { string | undefined } ID of the affected node or undefined
140+ * @param pId - ID of the node to perform action on
141+ * @param action - Action to perform (add, addChild, remove, up, down, left ,
142+ * right)
143+ * @returns ID of the affected node or undefined
150144 */
151145 run = ( pId : string , action : string ) => {
152146 const the = nodesMap . value [ pId ] ;
@@ -224,54 +218,53 @@ export default (
224218 /**
225219 * Adds a new sibling node after the specified node
226220 *
227- * @param { string } pId - ID of the node to add a sibling to
228- * @returns { string | undefined } ID of the newly added node
221+ * @param pId - ID of the node to add a sibling to
222+ * @returns ID of the newly added node
229223 */
230224 add : ( pId : string ) => run ( pId , "add" ) ,
231225 /**
232226 * Adds a new child node to the specified node
233227 *
234- * @param { string } pId - ID of the node to add a child to
235- * @returns { string | undefined } ID of the newly added child node
228+ * @param pId - ID of the node to add a child to
229+ * @returns ID of the newly added child node
236230 */
237231 addChild : ( pId : string ) => run ( pId , "addChild" ) ,
238232 /**
239233 * Moves the specified node one position down within its siblings
240234 *
241- * @param { string } pId - ID of the node to move down
242- * @returns { void }
235+ * @param pId - ID of the node to move down
236+ * @returns Undefined
243237 */
244238 down : ( pId : string ) => run ( pId , "down" ) ,
245239 /**
246240 * Moves the specified node one level up in the hierarchy, making it a
247241 * sibling of its parent
248242 *
249- * @param { string } pId - ID of the node to move left
250- * @returns { string | undefined } ID of the parent node if successful
243+ * @param pId - ID of the node to move left
244+ * @returns ID of the parent node if successful
251245 */
252246 left : ( pId : string ) => run ( pId , "left" ) ,
253247 nodes,
254248 nodesMap,
255249 /**
256250 * Removes the specified node from the tree
257251 *
258- * @param {string } pId - ID of the node to remove
259- * @returns {string | undefined } ID of the next node that gets focus after
260- * removal
252+ * @param pId - ID of the node to remove
253+ * @returns ID of the next node that gets focus after removal
261254 */
262255 remove : ( pId : string ) => run ( pId , "remove" ) ,
263256 /**
264257 * Moves the specified node as a child of the previous sibling
265258 *
266- * @param { string } pId - ID of the node to move right
267- * @returns { string | undefined } ID of the new parent node if successful
259+ * @param pId - ID of the node to move right
260+ * @returns ID of the new parent node if successful
268261 */
269262 right : ( pId : string ) => run ( pId , "right" ) ,
270263 /**
271264 * Moves the specified node one position up within its siblings
272265 *
273- * @param { string } pId - ID of the node to move up
274- * @returns { void }
266+ * @param pId - ID of the node to move up
267+ * @returns Undefined
275268 */
276269 up : ( pId : string ) => run ( pId , "up" ) ,
277270 } ;
0 commit comments