()
| 33 | } |
| 34 | |
| 35 | pop() { |
| 36 | let cur = this.head; |
| 37 | |
| 38 | // only one or no item exists |
| 39 | if (!cur) return null; |
| 40 | if (!cur.next) { |
| 41 | this.head = null; |
| 42 | return cur; |
| 43 | } |
| 44 | // move till the 2nd last |
| 45 | while (cur.next.next) |
| 46 | cur = cur.next; |
| 47 | |
| 48 | let last = this.tail; |
| 49 | this.tail = cur; |
| 50 | this.tail.next = null; |
| 51 | return last; |
| 52 | } |
| 53 | |
| 54 | popFirst() { |
| 55 | let first = this.head; |
nothing calls this directly
no outgoing calls
no test coverage detected