Skip to content

Commit 794d7f3

Browse files
authored
feat: tiny improvements for "convertValue" (#5302)
We don't need to check each value's satisfication so when one meets, the loop can be broken. Speed up config dump process. ## Summary by CodeRabbit - **Refactor** - Improved efficiency in handling `ignore` keys within utility functions. - Consolidated conditions for returning values for primitives and arrays, enhancing code readability.
1 parent 84b162f commit 794d7f3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/core/utils.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ function convertObject(obj, ignore) {
2020
function convertValue(key, value, ignore) {
2121
if (is.nullOrUndefined(value)) return value;
2222

23-
let hit;
23+
let hit = false;
2424
for (const matchKey of ignore) {
2525
if (is.string(matchKey) && matchKey === key) {
2626
hit = true;
27+
break;
2728
} else if (is.regExp(matchKey) && matchKey.test(key)) {
2829
hit = true;
30+
break;
2931
}
3032
}
3133
if (!hit) {
3234
if (is.symbol(value) || is.regExp(value)) return value.toString();
33-
if (is.primitive(value)) return value;
34-
if (is.array(value)) return value;
35+
if (is.primitive(value) || is.array(value)) return value;
3536
}
3637

3738
// only convert recursively when it's a plain object,

0 commit comments

Comments
 (0)