Installation
Quick Take
Purpose
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.
For example, 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.
API — collWhitespace()
The main function collWhitespace()
is imported like this:
It’s a function which takes two input arguments:
Input argument | Type | Obligatory | Default | Description |
---|---|---|---|---|
str Type: String Obligatory: yes Default: undefined | ||||
str | String | yes | undefined | Source string to work on |
lineBreakLimit Type: Natural number or zero Obligatory: no Default: 1 | ||||
lineBreakLimit | Natural number or zero | no | 1 | 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.
API — version
You can import version
: