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';
22import Node from './Node.js' ;
33
44/**
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.
67 *
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.
810 *
911 * @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.
1113 */
1214export default function * _iter ( first ) {
1315 assert ( first instanceof Node ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import Node from './Node.js';
66 * Generator of nodes in list in order.
77 *
88 * @param {Node } first First node of the list (can be null).
9- * @return {IterableIterator }
9+ * @return {IterableIterator<Node> }
1010 */
1111export default function * iter ( first ) {
1212 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';
66 * Removes last {@link Node} from a list. Throws if input list is empty.
77 *
88 * @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.
1010 */
1111export default function pop ( x ) {
1212 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';
55/**
66 * Removes first {@link Node} from a list. Throws if input list is empty.
77 *
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- *
118 * @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.
1310 */
1411export default function shift ( x ) {
1512 if ( x === null ) throw new Error ( 'input list is empty' ) ;
You can’t perform that action at this time.
0 commit comments