(self: Doc.Char<A> | Doc.Text<A>)
| 839 | } |
| 840 | |
| 841 | const sanitizeLeaf = <A>(self: Doc.Char<A> | Doc.Text<A>): Doc.Doc<A> => { |
| 842 | const value = self._tag === "Char" ? self.char : self.text |
| 843 | const sanitized = stripControlCharacters(value) |
| 844 | if (sanitized === value) { |
| 845 | return self |
| 846 | } |
| 847 | if (sanitized.length === 0) { |
| 848 | return empty |
| 849 | } |
| 850 | return sanitized.length === 1 ? char(sanitized) : text(sanitized) |
| 851 | } |
| 852 | |
| 853 | /** @internal */ |
| 854 | export const sanitize = <A>(self: Doc.Doc<A>): Doc.Doc<A> => Effect.runSync(sanitizeSafe(self)) |
no test coverage detected