|
1 | 1 | import { CdataEvent, CharactersEvent, EndElementEvent, StartElementEvent, StaxXmlParser, StaxXmlWriter, XmlEventType } from "stax-xml"; |
2 | 2 | import { Col, ColumnType, NexaVersion, Parameter, RowType, XapiOptions, XapiValueType } from "./types"; |
3 | | -import { base64ToUint8Array, dateToString, makeParseEntities, makeWriterEntities, stringToDate, uint8ArrayToBase64 } from "./utils"; |
| 3 | +import { base64ToUint8Array, dateToString, makeParseEntities, makeWriterEntities, stringToDate, StringWritableStream, uint8ArrayToBase64 } from "./utils"; |
4 | 4 | import { Dataset, XapiRoot } from "./xapi-data"; |
5 | 5 |
|
6 | 6 | const defaultOptions: XapiOptions = { |
@@ -210,6 +210,12 @@ function convertToString(value: XapiValueType, type: ColumnType): string { |
210 | 210 | } |
211 | 211 | } |
212 | 212 |
|
| 213 | +export async function writeString(root: XapiRoot): Promise<string> { |
| 214 | + const stringStream = new StringWritableStream(); |
| 215 | + await write(stringStream, root); |
| 216 | + return stringStream.getResult(); |
| 217 | +} |
| 218 | + |
213 | 219 | export async function write(stream: WritableStream<Uint8Array>, root: XapiRoot): Promise<void> { |
214 | 220 | const writer = new StaxXmlWriter(stream, { |
215 | 221 | addEntities: makeWriterEntities(), |
|
0 commit comments