@@ -67,14 +67,12 @@ export interface NormalizableLinksetInterface<T extends NormalizedLinksetInterfa
6767 * A set of links.
6868 * @internal
6969 */
70- export class Linkset implements NormalizableLinksetInterface < NormalizedLinksetInterface > , IterableIterator < LinkInterface > {
70+ export class Linkset implements NormalizableLinksetInterface < NormalizedLinksetInterface > {
7171 /**
7272 * {@inheritDoc LinksetInterface.elements }
7373 */
7474 readonly elements : LinkInterface [ ] ;
75- private iterationIndex : number ;
7675 constructor ( links : LinkInterface [ ] ) {
77- this . iterationIndex = 0 ;
7876 this . elements = links ;
7977 }
8078 /**
@@ -108,20 +106,20 @@ export class Linkset implements NormalizableLinksetInterface<NormalizedLinksetIn
108106 return new Linkset ( this . elements . filter ( ( link ) => link . anchor === anchor ) ) ;
109107 }
110108 /**
111- * Implements the IterableIterator interface .
109+ * Implements the iterable protocol .
112110 */
113- [ Symbol . iterator ] ( ) : IterableIterator < LinkInterface > {
114- return this ;
115- }
116- /**
117- * Implements the IterableIterator interface.
118- */
119- next ( ) : IteratorResult < LinkInterface > {
120- if ( this . iterationIndex < this . elements . length ) {
121- return { value : this . elements [ this . iterationIndex ++ ] , done : false } ;
122- } else {
123- return { value : undefined , done : true } ;
124- }
111+ [ Symbol . iterator ] ( ) : Iterator < LinkInterface > {
112+ const elems = this . elements ;
113+ let pointer = 0 ;
114+ return {
115+ next ( ) : IteratorResult < LinkInterface > {
116+ if ( pointer < elems . length ) {
117+ return { value : elems [ pointer ++ ] , done : false } ;
118+ } else {
119+ return { value : undefined , done : true } ;
120+ }
121+ }
122+ } ;
125123 }
126124 /**
127125 * {@inheritDoc NormalizableLinksetInterface.normalize }
0 commit comments