MCPcopy Create free account
hub / github.com/Effect-TS/effect / sanitizeLeaf

Function sanitizeLeaf

packages/printer/src/internal/doc.ts:841–851  ·  view source on GitHub ↗
(self: Doc.Char<A> | Doc.Text<A>)

Source from the content-addressed store, hash-verified

839}
840
841const 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 */
854export const sanitize = <A>(self: Doc.Doc<A>): Doc.Doc<A> => Effect.runSync(sanitizeSafe(self))

Callers 1

sanitizeSafeFunction · 0.85

Calls 3

stripControlCharactersFunction · 0.85
charFunction · 0.70
textFunction · 0.70

Tested by

no test coverage detected