You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 1.2KB

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