This program is aimed to process strings before concatenating them. It collapses the leading and trailing whitespace, if any, so that later the result looks reasonable.
ranges-push uses it to merge to-be-inserted chunks of string.
It does not touch the "inner" whitespace, gaps between chunks of text present between the first and last non-whitespace characters. See
string-collapse-white-space which processes those gaps.
The main function
collWhitespace() is imported like this:
It's a function which takes two input arguments:
|String||yes||undefined||Source string to work on|
|Natural number or zero||no||If whitespace contains linebreaks, it will be replaced by those linebreaks, count limited to this value|
If first input argument is not a string, it will be just returned back, untouched.
If second input argument is zero or falsy or not a number, it will be set to
1 and application will continue as normal.
The function will return a string of zero or more characters. If input was not a string, same input will be returned back, without an error.
You can import