Merge pull request #29783 from tlaziuk/range-parser

[range-parser] fix babel7's --isolatedModules recommended option
This commit is contained in:
Andrew Casey 2018-12-07 11:18:46 -08:00 committed by GitHub
commit a7e3258535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -4,11 +4,11 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns `-1` when unsatisfiable and `-2` when syntactically invalid.
*
* When ranges are returned, the array has a "type" property which is the type of
* range that is required (most commonly, "bytes"). Each array element is an object
* with a "start" and "end" property for the portion of the range.
*
* @returns `-1` when unsatisfiable and `-2` when syntactically invalid, ranges otherwise.
*/
declare function RangeParser(size: number, str: string, options?: RangeParser.Options): RangeParser.Result | RangeParser.Ranges;
@ -27,10 +27,9 @@ declare namespace RangeParser {
*/
combine?: boolean;
}
const enum Result {
invaild = -2,
unsatisifiable = -1,
}
type ResultUnsatisfiable = -1;
type ResultInvalid = -2;
type Result = ResultUnsatisfiable | ResultInvalid;
}
export = RangeParser;

View File

@ -2,8 +2,8 @@ import RangeParser = require('range-parser');
declare var console: { assert(b: boolean): void };
console.assert(RangeParser(200, `malformed`) === RangeParser.Result.invaild);
console.assert(RangeParser(200, `bytes=500-20`) === RangeParser.Result.unsatisifiable);
console.assert(RangeParser(200, `malformed`) === -2);
console.assert(RangeParser(200, `bytes=500-20`) === -1);
const range = RangeParser(1000, `bytes=0-499`);

View File

@ -20,4 +20,4 @@
"index.d.ts",
"range-parser-tests.ts"
]
}
}