MCPcopy Create free account
hub / github.com/denoland/std / generateWithTrailingIncomplete

Function generateWithTrailingIncomplete

xml/parse_stream_test.ts:676–682  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

674 // The stream must END with incomplete UTF-8 bytes, so the final decode() produces output
675
676 async function* generateWithTrailingIncomplete(): AsyncGenerator<Uint8Array> {
677 // Valid complete XML
678 yield new TextEncoder().encode("<root>test</root>");
679 // Trailing incomplete UTF-8: first byte of a 2-byte sequence with no continuation
680 // This byte will be buffered during streaming decode and flushed at the end
681 yield new Uint8Array([0xC2]); // Incomplete 2-byte sequence (expects 0x80-0xBF to follow)
682 }
683
684 // The XML parser will see the replacement character after the closing tag
685 // which causes "Cannot have content after the root element"

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected