mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Make item loop iterative (vs. recursive) to handle synchronous processing of thousands of items.
This commit is contained in:
parent
f80b61d8b7
commit
ff73e822cf
1 changed files with 36 additions and 27 deletions
|
@ -445,35 +445,44 @@ function lintInput(options, synchronous, callback) {
|
|||
var resultVersion = (options.resultVersion === undefined) ?
|
||||
2 : options.resultVersion;
|
||||
var results = newResults(ruleList);
|
||||
// Helper to lint the next string or file item
|
||||
var item = null;
|
||||
function lintNextItem(err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else if (result) {
|
||||
// Helper to lint the next string or file
|
||||
function lintNextItem() {
|
||||
var iterating = true;
|
||||
var item = null;
|
||||
function lintNextItemCallback(err, result) {
|
||||
if (err) {
|
||||
iterating = false;
|
||||
return callback(err);
|
||||
}
|
||||
results[item] = result;
|
||||
if (!iterating) {
|
||||
lintNextItem();
|
||||
}
|
||||
}
|
||||
if ((item = stringsKeys.shift())) {
|
||||
lintContent(
|
||||
ruleList,
|
||||
strings[item] || "",
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
lintNextItem);
|
||||
} else if ((item = files.shift())) {
|
||||
lintFile(
|
||||
ruleList,
|
||||
item,
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
synchronous,
|
||||
lintNextItem);
|
||||
} else {
|
||||
callback(null, results);
|
||||
while (iterating) {
|
||||
if ((item = stringsKeys.shift())) {
|
||||
lintContent(
|
||||
ruleList,
|
||||
strings[item] || "",
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
lintNextItemCallback);
|
||||
} else if ((item = files.shift())) {
|
||||
iterating = synchronous;
|
||||
lintFile(
|
||||
ruleList,
|
||||
item,
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
synchronous,
|
||||
lintNextItemCallback);
|
||||
} else {
|
||||
return callback(null, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
lintNextItem();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue