For example, when working on parsed tokens, we have a value, a chunk of string, but we know it starts at an index X, not at an index zero. When we return a zero-based result, the receiving parties need to increment every index by X. This program performs this incrementing. The catch is, empty Ranges are typically
null (not an empty array) so the
Array.prototype.map() can't be used. Hence this library.
The main function
rOffset() is imported like this:
It's a function which takes three input arguments:
|null or Array of one or more arrays (Ranges)||no||Provide an array of ranges to invert. Ranges do not have to be sorted or merged.|
|Integer number||no||This number will be added to each index of every range.|
- if not ranges were passed, array of one or more arrays, same input will be returned
- ELSE, offset value will be added to each index of every range
Inputs are not mutated.