js: Simplify indexing arrays from the end with Array#at.

https://github.com/tc39/proposal-relative-indexing-method

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-01-24 00:05:06 -08:00
committed by Tim Abbott
parent 0b03628324
commit c6b372b471
13 changed files with 26 additions and 33 deletions

View File

@@ -209,18 +209,18 @@ export function process_fenced_code(content) {
handler_stack.push(current_handler);
for (const line of input) {
const handler = handler_stack[handler_stack.length - 1];
const handler = handler_stack.at(-1);
handler.handle_line(line);
}
// Clean up all trailing blocks by letting them
// insert closing fences
while (handler_stack.length !== 0) {
const handler = handler_stack[handler_stack.length - 1];
const handler = handler_stack.at(-1);
handler.done();
}
if (output.length > 2 && output[output.length - 2] !== "") {
if (output.length > 2 && output.at(-2) !== "") {
output.push("");
}