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

Function words

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

Source from the content-addressed store, hash-verified

944
945/** @internal */
946export const words = (str: string, splitChar = " "): ReadonlyArray<Doc.Doc<never>> =>
947 str.split(splitChar).map((word) => {
948 if (word === "") {
949 return empty
950 }
951 if (word === "\n") {
952 return hardLine
953 }
954 if (word.length === 1) {
955 return char(word)
956 }
957 return text(word)
958 })
959
960/** @internal */
961export 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