Installation
Quick Take
API — rInvert()
The main function rInvert()
is imported like this:
It’s a function which takes three input arguments:
Input argument | Type | Obligatory | Description |
---|---|---|---|
arrOfRanges Type: null or array of zero or more arraysObligatory: yes | |||
arrOfRanges | null or array of zero or more arrays | yes | Provide an array of ranges to invert. Ranges do not have to be sorted or merged. |
strLen Type: Integer number Obligatory: yes | |||
strLen | Integer number | yes | Algorithm needs to know the length of the reference string to calculate the inverted last slice’s ending index. |
opts Type: Plain object Obligatory: no | |||
opts | Plain object | no | Optional Options Object. |
The Optional Options Object has the following shape:
Key | Type | Obligatory | Default | Description |
---|---|---|---|---|
strictlyTwoElementsInRangeArrays Type: Boolean Obligatory: no Default: false | ||||
strictlyTwoElementsInRangeArrays | Boolean | no | false | If set to true, all ranges must have two and only two elements, otherwise an error will be thrown. For example, input being [ [1, 2, 'zzz'] ] would throw (because of 3 elements), as well as [ ['a'] ] (1 element). |
skipChecks Type: Boolean Obligatory: no Default: false | ||||
skipChecks | Boolean | no | false | If set to true, no checks will be performed. It’s handy to cut corners for perf reasons when you know input ranges are clean. |
Here are all defaults in one place for copying:
Function will return inverted ranges — a null
or array of one or more range arrays:
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
: