From 8c88dd1625295a02e52ec820a1dd2e2f5675287c Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Thu, 7 Apr 2022 21:46:05 +0900 Subject: [PATCH] update --- src/convert.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/convert.ts b/src/convert.ts index 98b691d..d1bc759 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -93,7 +93,7 @@ class PreTokens { this.index-- } - public forEach(callback: (cst: NormalSourceToken) => void) { + public each(callback: (cst: NormalSourceToken) => void) { let cst while ((cst = this.consume())) { callback(cst) @@ -396,7 +396,11 @@ function convertDocumentBody( if (cst) { return convertContentNode(preTokens, cst, node, ctx, parent, parent) } - preTokens.forEach((t) => processAnyToken(t, ctx)) + const token = preTokens.first() + /* istanbul ignore if */ + if (token) { + throw ctx.throwUnexpectedTokenError(token) + } return null } @@ -1482,7 +1486,7 @@ function convertAnchorAndTag( return meta } - preTokens.forEach((cst) => { + preTokens.each((cst) => { if (isAnchorCST(cst)) { const ast = getMetaAst(cst) const anchor = convertAnchor(cst, ctx, ast, doc) @@ -1500,7 +1504,7 @@ function convertAnchorAndTag( throw ctx.throwUnexpectedTokenError(cst) } }) - return meta || (value as never) + return meta || value! } /**