```js
matchFn: (count, canRetryLimit, filePath, suffixes) => {
if (utils.isDirectory(filePath)) {
const files = fs.readdirSync(filePath);
for (const file of files) {
const found = utils.matchFn(count, canRetryLimit, `${filePath}/${file}`, suffixes);
if (found) {
return true;
}
}
} else {
count -= 1;
if (filePath.match(new RegExp(`(${suffixes.join('|')})$`))) {
return true;
}
}
return false;
}
```

我想实现的是递归检查目标文件夹中是不是有命中目标后缀的文件,最多尝试 N 次。
如上是基本实现,但是明显有错,else logic 下 count 没有正确消费上,请问如何改进下呢。
matchFn: (count, canRetryLimit, filePath, suffixes) => {
if (utils.isDirectory(filePath)) {
const files = fs.readdirSync(filePath);
for (const file of files) {
const found = utils.matchFn(count, canRetryLimit, `${filePath}/${file}`, suffixes);
if (found) {
return true;
}
}
} else {
count -= 1;
if (filePath.match(new RegExp(`(${suffixes.join('|')})$`))) {
return true;
}
}
return false;
}
```

我想实现的是递归检查目标文件夹中是不是有命中目标后缀的文件,最多尝试 N 次。
如上是基本实现,但是明显有错,else logic 下 count 没有正确消费上,请问如何改进下呢。