mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01: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) ?
|
var resultVersion = (options.resultVersion === undefined) ?
|
||||||
2 : options.resultVersion;
|
2 : options.resultVersion;
|
||||||
var results = newResults(ruleList);
|
var results = newResults(ruleList);
|
||||||
// Helper to lint the next string or file item
|
// Helper to lint the next string or file
|
||||||
var item = null;
|
function lintNextItem() {
|
||||||
function lintNextItem(err, result) {
|
var iterating = true;
|
||||||
if (err) {
|
var item = null;
|
||||||
return callback(err);
|
function lintNextItemCallback(err, result) {
|
||||||
} else if (result) {
|
if (err) {
|
||||||
|
iterating = false;
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
results[item] = result;
|
results[item] = result;
|
||||||
|
if (!iterating) {
|
||||||
|
lintNextItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((item = stringsKeys.shift())) {
|
while (iterating) {
|
||||||
lintContent(
|
if ((item = stringsKeys.shift())) {
|
||||||
ruleList,
|
lintContent(
|
||||||
strings[item] || "",
|
ruleList,
|
||||||
config,
|
strings[item] || "",
|
||||||
frontMatter,
|
config,
|
||||||
noInlineConfig,
|
frontMatter,
|
||||||
resultVersion,
|
noInlineConfig,
|
||||||
lintNextItem);
|
resultVersion,
|
||||||
} else if ((item = files.shift())) {
|
lintNextItemCallback);
|
||||||
lintFile(
|
} else if ((item = files.shift())) {
|
||||||
ruleList,
|
iterating = synchronous;
|
||||||
item,
|
lintFile(
|
||||||
config,
|
ruleList,
|
||||||
frontMatter,
|
item,
|
||||||
noInlineConfig,
|
config,
|
||||||
resultVersion,
|
frontMatter,
|
||||||
synchronous,
|
noInlineConfig,
|
||||||
lintNextItem);
|
resultVersion,
|
||||||
} else {
|
synchronous,
|
||||||
callback(null, results);
|
lintNextItemCallback);
|
||||||
|
} else {
|
||||||
|
return callback(null, results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lintNextItem();
|
lintNextItem();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue