Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit ad4d02b

Browse files
author
tkrause
committed
bugfix: the array was modified while iterating
1 parent e81b9c6 commit ad4d02b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/workers/api_use.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
8080
]
8181
);
8282
}
83+
84+
//create a copy of the elements for save iterating of the elements
85+
const blockClone = [...block.local[target]];
8386

84-
block.local[target].forEach(function(definition) {
87+
// remove unneeded target before starting the loop, to allow a save insertion of new elements
88+
// TODO: create a cleanup filter
89+
delete block.local[target];
90+
91+
blockClone.forEach(function(definition) {
8592
var name = definition.name;
8693
var version = block.version || packageInfos.defaultVersion;
8794

@@ -135,10 +142,6 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
135142
matchedData = preProcess[source][name][versionName];
136143
}
137144

138-
// remove target, not needed anymore
139-
// TODO: create a cleanup filter
140-
delete block.local[target];
141-
142145
// copy matched elements into parsed block
143146
_recursiveMerge(block.local, matchedData);
144147
});

0 commit comments

Comments
 (0)