namespace LinkedListIteratorUsingGenerator { class LinkedListNode < T > { value : T ; next : LinkedListNode < T > | undefined ; constructor ( value ) { this . value = value ; } } function * linkedListIterator < T > ( head ) { let current = head ; while ( current ) { yield current . value ; current = current . next ; } } }