Skip to content

Commit ab561c0

Browse files
tniessentargos
authored andcommittedMar 27, 2018
tools: shorten metadata parsing
PR-URL: #19512 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 0db7b8c commit ab561c0

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 

‎tools/doc/common.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,28 @@ function arrify(value) {
1313
}
1414

1515
function extractAndParseYAML(text) {
16-
text = text.trim();
17-
18-
text = text.replace(/^<!-- YAML/, '')
16+
text = text.trim()
17+
.replace(/^<!-- YAML/, '')
1918
.replace(/-->$/, '');
2019

2120
// js-yaml.safeLoad() throws on error
2221
const meta = yaml.safeLoad(text);
2322

24-
const added = meta.added;
25-
if (added) {
23+
if (meta.added) {
2624
// Since semver-minors can trickle down to previous major versions,
2725
// features may have been added in multiple versions.
28-
meta.added = arrify(added);
26+
meta.added = arrify(meta.added);
2927
}
3028

31-
const deprecated = meta.deprecated;
32-
if (deprecated) {
29+
if (meta.deprecated) {
3330
// Treat deprecated like added for consistency.
34-
meta.deprecated = arrify(deprecated);
31+
meta.deprecated = arrify(meta.deprecated);
3532
}
3633

3734
meta.changes = meta.changes || [];
38-
meta.changes.forEach((entry) => {
35+
for (const entry of meta.changes) {
3936
entry.description = entry.description.replace(/^\^\s*/, '');
40-
});
37+
}
4138

4239
return meta;
4340
}

0 commit comments

Comments
 (0)
Please sign in to comment.