MCPcopy
hub / github.com/Effect-TS/effect / words

Function words

packages/printer/src/internal/doc.ts:863–875  ·  view source on GitHub ↗
(str: string, splitChar = " ")

Source from the content-addressed store, hash-verified

861
862/** @internal */
863export const words = (str: string, splitChar = " "): ReadonlyArray<Doc.Doc<never>> =>
864 str.split(splitChar).map((word) => {
865 if (word === "") {
866 return empty
867 }
868 if (word === "\n") {
869 return hardLine
870 }
871 if (word.length === 1) {
872 return char(word)
873 }
874 return text(word)
875 })
876
877/** @internal */
878export const reflow = (s: string, char = " "): Doc.Doc<never> => fillSep(words(s, char))

Callers 1

reflowFunction · 0.85

Calls 4

splitMethod · 0.80
charFunction · 0.70
textFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected