Function
words
(str: string, splitChar = " ")
Source from the content-addressed store, hash-verified
| 944 | |
| 945 | /** @internal */ |
| 946 | export 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 */ |
| 961 | export const reflow = (s: string, char = " "): Doc.Doc<never> => fillSep(words(s, char)) |
Tested by
no test coverage detected