| 1 |
/** |
| 2 |
* When ranges are returned, the array has a "type" property which is the type of |
| 3 |
* range that is required (most commonly, "bytes"). Each array element is an object |
| 4 |
* with a "start" and "end" property for the portion of the range. |
| 5 |
* |
| 6 |
* @returns `-1` when unsatisfiable and `-2` when syntactically invalid, ranges otherwise. |
| 7 |
*/ |
| 8 |
declare function RangeParser( |
| 9 |
size: number, |
| 10 |
str: string, |
| 11 |
options?: RangeParser.Options, |
| 12 |
): RangeParser.Result | RangeParser.Ranges; |
| 13 |
|
| 14 |
declare namespace RangeParser { |
| 15 |
interface Ranges extends Array<Range> { |
| 16 |
type: string; |
| 17 |
} |
| 18 |
interface Range { |
| 19 |
start: number; |
| 20 |
end: number; |
| 21 |
} |
| 22 |
interface Options { |
| 23 |
/** |
| 24 |
* The "combine" option can be set to `true` and overlapping & adjacent ranges |
| 25 |
* will be combined into a single range. |
| 26 |
*/ |
| 27 |
combine?: boolean | undefined; |
| 28 |
} |
| 29 |
type ResultUnsatisfiable = -1; |
| 30 |
type ResultInvalid = -2; |
| 31 |
type Result = ResultUnsatisfiable | ResultInvalid; |
| 32 |
} |
| 33 |
|
| 34 |
export = RangeParser; |