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