File tree Expand file tree Collapse file tree 4 files changed +8
-9
lines changed Expand file tree Collapse file tree 4 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,14 @@ import assert from 'assert';
2
2
import Node from './Node.js' ;
3
3
4
4
/**
5
- * Generator of nodes in list in order.
5
+ * Generator of nodes in list in order. You are allowed to edit the current
6
+ * node.
6
7
*
7
- * TODO yield values/keys instead?
8
+ * /!\ Modifying the next pointer of the current node will NOT change which
9
+ * node comes next in the iteration.
8
10
*
9
11
* @param {Node } first First node of the list.
10
- * @return {IterableIterator } Yields nodes of a list in order.
12
+ * @return {IterableIterator<Node> } Yields nodes of a list in order.
11
13
*/
12
14
export default function * _iter ( first ) {
13
15
assert ( first instanceof Node ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import Node from './Node.js';
6
6
* Generator of nodes in list in order.
7
7
*
8
8
* @param {Node } first First node of the list (can be null).
9
- * @return {IterableIterator }
9
+ * @return {IterableIterator<Node> }
10
10
*/
11
11
export default function * iter ( first ) {
12
12
assert ( first === null || first instanceof Node ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import _remove from './_remove.js';
6
6
* Removes last {@link Node} from a list. Throws if input list is empty.
7
7
*
8
8
* @param {Node } x First node.
9
- * @return {[Node, Node] } New list (possibly null) and popped node.
9
+ * @return {[Node, Node] } New list (possibly null) and removed node.
10
10
*/
11
11
export default function pop ( x ) {
12
12
if ( x === null ) throw new Error ( 'input list is empty' ) ;
Original file line number Diff line number Diff line change @@ -5,11 +5,8 @@ import _remove from './_remove.js';
5
5
/**
6
6
* Removes first {@link Node} from a list. Throws if input list is empty.
7
7
*
8
- * TODO I do not think we need to return the popped node since it is x.
9
- * Currently this is kept so to have the same signature as {@link pop}.
10
- *
11
8
* @param {Node } x First node .
12
- * @return {[Node, Node] } New list (possibly null) and popped node.
9
+ * @return {[Node, Node] } New list (possibly null) and removed node.
13
10
*/
14
11
export default function shift ( x ) {
15
12
if ( x === null ) throw new Error ( 'input list is empty' ) ;
You can’t perform that action at this time.
0 commit comments