Skip to content

Commit 7ed7b22

Browse files
BridgeARaddaleax
authored andcommitted
tools: change var to const in ./license2rtf
PR-URL: #13732 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent f3bff93 commit 7ed7b22

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

tools/license2rtf.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function LineSplitter() {
1616
this.writable = true;
1717

1818
this.write = function(data) {
19-
var lines = (buffer + data).split(/\r\n|\n\r|\n|\r/);
19+
const lines = (buffer + data).split(/\r\n|\n\r|\n|\r/);
2020
for (var i = 0; i < lines.length - 1; i++) {
2121
self.emit('data', lines[i]);
2222
}
@@ -128,18 +128,18 @@ function ParagraphParser() {
128128
}
129129

130130
// Find out indentation level and the start of a lied or numbered list;
131-
var result = /^(\s*)(\d+\.|\*|-)?\s*/.exec(line);
131+
const result = /^(\s*)(\d+\.|\*|-)?\s*/.exec(line);
132132
assert.ok(result);
133133
// The number of characters that will be stripped from the beginning of
134134
// the line.
135-
var line_strip_length = result[0].length;
135+
const line_strip_length = result[0].length;
136136
// The indentation size that will be used to detect indentation jumps.
137137
// Fudge by 1 space.
138-
var line_indent = Math.floor(result[0].length / 2) * 2;
138+
const line_indent = Math.floor(line_strip_length / 2) * 2;
139139
// The indentation level that will be exported
140-
var level = Math.floor(result[1].length / 2);
140+
const level = Math.floor(result[1].length / 2);
141141
// The list indicator that precedes the actual content, if any.
142-
var line_li = result[2];
142+
const line_li = result[2];
143143

144144
// Flush the paragraph when there is a li or an indentation jump
145145
if (line_li || (line_indent !== paragraph_line_indent &&
@@ -175,14 +175,14 @@ inherits(ParagraphParser, Stream);
175175
* replaces multiple consecutive whitespace characters by a single one.
176176
*/
177177
function Unwrapper() {
178-
var self = this;
178+
const self = this;
179179

180180
Stream.call(this);
181181
this.writable = true;
182182

183183
this.write = function(paragraph) {
184-
var lines = paragraph.lines;
185-
var break_after = [];
184+
const lines = paragraph.lines;
185+
const break_after = [];
186186
var i;
187187

188188
for (i = 0; i < lines.length - 1; i++) {
@@ -236,15 +236,14 @@ function RtfGenerator() {
236236
Stream.call(this);
237237
this.writable = true;
238238

239-
this.write = function(paragraph) {
239+
this.write = function({ li, level, lines, in_license_block: lic }) {
240240
if (!did_write_anything) {
241241
emitHeader();
242242
did_write_anything = true;
243243
}
244244

245-
var li = paragraph.li;
246-
var level = paragraph.level + (li ? 1 : 0);
247-
var lic = paragraph.in_license_block;
245+
if (li)
246+
level++;
248247

249248
var rtf = '\\pard';
250249
rtf += '\\sa150\\sl300\\slmult1';
@@ -261,7 +260,7 @@ function RtfGenerator() {
261260
if (li)
262261
rtf += ' ' + li + '\\tab';
263262
rtf += ' ';
264-
rtf += paragraph.lines.map(rtfEscape).join('\\line ');
263+
rtf += lines.map(rtfEscape).join('\\line ');
265264
if (!lic)
266265
rtf += '\\b0';
267266
rtf += '\\par\n';

0 commit comments

Comments
 (0)