From ac692668073d8fb7790c60f799d64d100049c68f Mon Sep 17 00:00:00 2001 From: jjrv Date: Tue, 6 Mar 2018 17:23:48 +0200 Subject: [PATCH] Allow embedding raw text in XML writer input. --- src/writer/Writer.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/writer/Writer.ts b/src/writer/Writer.ts index ae99791..820eb5d 100644 --- a/src/writer/Writer.ts +++ b/src/writer/Writer.ts @@ -29,7 +29,7 @@ export class Writer extends stream.Transform { super({ objectMode: true }); } - transform(chunk: TokenChunk | TokenBuffer, partList: string[]) { + transform(chunk: TokenChunk | TokenBuffer | string, partList: string[]) { const prefixList = this.prefixList; const chunkCount = this.chunkCount++; let buffer: TokenBuffer; @@ -47,8 +47,11 @@ export class Writer extends stream.Transform { let tokenNum = -1; let namespaceList: (Namespace | undefined)[] | undefined; - if(chunk instanceof TokenChunk) { - buffer = chunk.buffer + if(typeof(chunk) == 'string') { + partList.push(chunk); + return(partList); + } else if(chunk instanceof TokenChunk) { + buffer = chunk.buffer; namespaceList = chunk.namespaceList; } else { buffer = chunk;