Installation
Quick Take
The Purpose
This program is used to manage the whitespace in the string index selections. Let’s say we want to delete certain index range in a string but maybe there is whitespace around? This program extends the index ranges as needed.
API — expander()
The main function expander() is imported like this:
It’s a function which takes one input argument:
| Input argument | Type | Obligatory | Description |
|---|---|---|---|
optsType: Plain object Obligatory: yes | |||
opts | Plain object | yes | An Options Object. See below for its API. |
The Options Object has the following shape:
| Key | Type | Obligatory | Default | Description |
|---|---|---|---|---|
strType: string Obligatory: yes Default: "" (empty) | ||||
str | string | yes | "" (empty) | String to reference |
fromType: number (natural number) Obligatory: yes Default: 0 | ||||
from | number (natural number) | yes | 0 | Index from which we should expand backwards |
toType: number (natural number) Obligatory: yes Default: 0 | ||||
to | number (natural number) | yes | 0 | Index from which we should expand backwards |
ifLeftSideIncludesThisThenCropTightlyType: string Obligatory: no Default: "" (empty) | ||||
ifLeftSideIncludesThisThenCropTightly | string | no | "" (empty) | All characters to the left side of given range you want to tigger a tight crop. All concatenated into one chunk. |
ifLeftSideIncludesThisCropItTooType: string Obligatory: no Default: "" (empty) | ||||
ifLeftSideIncludesThisCropItToo | string | no | "" (empty) | All characters to the left side of given range you want to skip as if they were whitespace |
ifRightSideIncludesThisThenCropTightlyType: string Obligatory: no Default: "" (empty) | ||||
ifRightSideIncludesThisThenCropTightly | string | no | "" (empty) | All characters to the right side of given range you want to tigger a tight crop. All concatenated into one chunk. |
ifRightSideIncludesThisCropItTooType: string Obligatory: no Default: "" (empty) | ||||
ifRightSideIncludesThisCropItToo | string | no | "" (empty) | All characters to the right side of given range you want to skip as if they were whitespace |
extendToOneSideType: Boolean false or strings “left” or “right”Obligatory: no Default: false | ||||
extendToOneSide | Boolean false or strings “left” or “right” | no | false | You can expand the range only to one side if you want using this. |
wipeAllWhitespaceOnLeftType: Boolean Obligatory: no Default: false | ||||
wipeAllWhitespaceOnLeft | Boolean | no | false | If on, range will be extended to the left until it reaches the first non-whitespace character (or EOL) |
wipeAllWhitespaceOnRightType: Boolean Obligatory: no Default: false | ||||
wipeAllWhitespaceOnRight | Boolean | no | false | If on, range will be extended to the right until it reaches the first non-whitespace character (or EOL) |
addSingleSpaceToPreventAccidentalConcatenationType: Boolean Obligatory: no Default: false | ||||
addSingleSpaceToPreventAccidentalConcatenation | Boolean | no | false | If on, it will prevent accidental concatenation of strings by inserting a single space in tight crop situations |
Here are all defaults in one place for copying:
The function will return an array of two indexes, the new “from” and new “to”. For example, [12, 14].
API — defaults
You can import defaults:
It's a plain object:
The main function calculates the options to be used by merging the options you passed with these defaults.
API — version
You can import version: