@@ -67,28 +67,29 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
6767 parsedFiles . forEach ( function ( parsedFile , parsedFileIndex ) {
6868 parsedFile . forEach ( function ( block ) {
6969 var loopCounter = 0 ; //add a loop counter to have a break condition when the recursion depth exceed a predifined limit
70- while ( block . local [ target ] ) {
71- if ( loopCounter > 10 ) {
72- throw new WorkerError ( 'recursion depth exceeds limit with @apiUse' ,
73- filenames [ parsedFileIndex ] ,
74- block . index ,
75- messages . common . element ,
76- messages . common . usage ,
77- messages . common . example ,
78- [
79- { 'Groupname' : name }
80- ]
70+ while ( block . local [ target ] ) {
71+ if ( loopCounter > 10 ) {
72+ throw new WorkerError ( 'recursion depth exceeds limit with @apiUse' ,
73+ filenames [ parsedFileIndex ] ,
74+ block . index ,
75+ messages . common . element ,
76+ messages . common . usage ,
77+ messages . common . example ,
78+ [
79+ { 'Groupname' : block . name }
80+ ]
8181 ) ;
82- }
82+ }
8383
8484 //create a copy of the elements for save iterating of the elements
85- const blockClone = [ ... block . local [ target ] ] ;
85+ var blockClone = block . local [ target ] . slice ( ) ;
8686
8787 // remove unneeded target before starting the loop, to allow a save insertion of new elements
8888 // TODO: create a cleanup filter
8989 delete block . local [ target ] ;
9090
91- blockClone . forEach ( function ( definition ) {
91+ for ( var blockIndex = 0 ; blockIndex < blockClone . length ; ++ blockIndex ) {
92+ var definition = blockClone [ blockIndex ] ;
9293 var name = definition . name ;
9394 var version = block . version || packageInfos . defaultVersion ;
9495
@@ -115,12 +116,13 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
115116 var lastVersion = packageInfos . defaultVersion ;
116117
117118 var versionKeys = Object . keys ( preProcess [ source ] [ name ] ) ;
118- versionKeys . forEach ( function ( currentVersion , versionIndex ) {
119+ for ( var versionIndex = 0 ; versionIndex < versionKeys . length ; ++ versionIndex ) {
120+ var currentVersion = versionKeys [ versionIndex ] ;
119121 if ( semver . gte ( version , currentVersion ) && semver . gte ( currentVersion , lastVersion ) ) {
120122 lastVersion = currentVersion ;
121123 foundIndex = versionIndex ;
122124 }
123- } ) ;
125+ }
124126
125127 if ( foundIndex === - 1 ) {
126128 throw new WorkerError ( 'Referenced definition has no matching or a higher version. ' +
@@ -144,7 +146,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
144146
145147 // copy matched elements into parsed block
146148 _recursiveMerge ( block . local , matchedData ) ;
147- } ) ;
149+ }
148150 }
149151 } ) ;
150152 } ) ;
0 commit comments