UNPKG

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