Skip to content

Commit 148f49f

Browse files
BridgeARaddaleax
authored andcommitted
tools: change var to const in ./doc/json
PR-URL: #13732 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent b89c27d commit 148f49f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

tools/doc/json.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const common = require('./common.js');
3030
const marked = require('marked');
3131

3232
// customized heading without id attribute
33-
var renderer = new marked.Renderer();
33+
const renderer = new marked.Renderer();
3434
renderer.heading = function(text, level) {
3535
return '<h' + level + '>' + text + '</h' + level + '>\n';
3636
};
@@ -39,14 +39,14 @@ marked.setOptions({
3939
});
4040

4141
function doJSON(input, filename, cb) {
42-
var root = {source: filename};
43-
var stack = [root];
42+
const root = {source: filename};
43+
const stack = [root];
4444
var depth = 0;
4545
var current = root;
4646
var state = null;
47-
var lexed = marked.lexer(input);
47+
const lexed = marked.lexer(input);
4848
lexed.forEach(function(tok) {
49-
var type = tok.type;
49+
const type = tok.type;
5050
var text = tok.text;
5151

5252
// <!-- type = module -->
@@ -223,14 +223,14 @@ function doJSON(input, filename, cb) {
223223
// default: 'false' } ] } ]
224224

225225
function processList(section) {
226-
var list = section.list;
227-
var values = [];
226+
const list = section.list;
227+
const values = [];
228228
var current;
229-
var stack = [];
229+
const stack = [];
230230

231231
// for now, *just* build the heirarchical list
232232
list.forEach(function(tok) {
233-
var type = tok.type;
233+
const type = tok.type;
234234
if (type === 'space') return;
235235
if (type === 'list_item_start' || type === 'loose_item_start') {
236236
var n = {};
@@ -329,7 +329,7 @@ function parseSignature(text, sig) {
329329
params = params[1];
330330
params = params.split(/,/);
331331
var optionalLevel = 0;
332-
var optionalCharDict = {'[': 1, ' ': 0, ']': -1};
332+
const optionalCharDict = {'[': 1, ' ': 0, ']': -1};
333333
params.forEach(function(p, i) {
334334
p = p.trim();
335335
if (!p) return;
@@ -351,7 +351,7 @@ function parseSignature(text, sig) {
351351
}
352352
p = p.substring(0, pos + 1);
353353

354-
var eq = p.indexOf('=');
354+
const eq = p.indexOf('=');
355355
if (eq !== -1) {
356356
def = p.substr(eq + 1);
357357
p = p.substr(0, eq);
@@ -381,8 +381,8 @@ function parseListItem(item) {
381381
// text = text.replace(/^(Argument|Param)s?\s*:?\s*/i, '');
382382

383383
text = text.replace(/^, /, '').trim();
384-
var retExpr = /^returns?\s*:?\s*/i;
385-
var ret = text.match(retExpr);
384+
const retExpr = /^returns?\s*:?\s*/i;
385+
const ret = text.match(retExpr);
386386
if (ret) {
387387
item.name = 'return';
388388
text = text.replace(retExpr, '');
@@ -396,24 +396,24 @@ function parseListItem(item) {
396396
}
397397

398398
text = text.trim();
399-
var defaultExpr = /\(default\s*[:=]?\s*['"`]?([^, '"`]*)['"`]?\)/i;
400-
var def = text.match(defaultExpr);
399+
const defaultExpr = /\(default\s*[:=]?\s*['"`]?([^, '"`]*)['"`]?\)/i;
400+
const def = text.match(defaultExpr);
401401
if (def) {
402402
item.default = def[1];
403403
text = text.replace(defaultExpr, '');
404404
}
405405

406406
text = text.trim();
407-
var typeExpr = /^\{([^}]+)\}/;
408-
var type = text.match(typeExpr);
407+
const typeExpr = /^\{([^}]+)\}/;
408+
const type = text.match(typeExpr);
409409
if (type) {
410410
item.type = type[1];
411411
text = text.replace(typeExpr, '');
412412
}
413413

414414
text = text.trim();
415-
var optExpr = /^Optional\.|(?:, )?Optional$/;
416-
var optional = text.match(optExpr);
415+
const optExpr = /^Optional\.|(?:, )?Optional$/;
416+
const optional = text.match(optExpr);
417417
if (optional) {
418418
item.optional = true;
419419
text = text.replace(optExpr, '');
@@ -556,19 +556,19 @@ function deepCopy_(src) {
556556

557557

558558
// these parse out the contents of an H# tag
559-
var eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
560-
var classExpr = /^Class:\s*([^ ]+).*$/i;
561-
var propExpr = /^[^.]+\.([^ .()]+)\s*$/;
562-
var braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/;
563-
var classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i;
564-
var methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/;
565-
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/;
559+
const eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
560+
const classExpr = /^Class:\s*([^ ]+).*$/i;
561+
const propExpr = /^[^.]+\.([^ .()]+)\s*$/;
562+
const braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/;
563+
const classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i;
564+
const methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/;
565+
const newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/;
566566
var paramExpr = /\((.*)\);?$/;
567567

568568
function newSection(tok) {
569-
var section = {};
569+
const section = {};
570570
// infer the type from the text.
571-
var text = section.textRaw = tok.text;
571+
const text = section.textRaw = tok.text;
572572
if (text.match(eventExpr)) {
573573
section.type = 'event';
574574
section.name = text.replace(eventExpr, '$1');

0 commit comments

Comments
 (0)