mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-15 06:20:23 +00:00
Merge pull request #14475 from tlaziuk/range-parser
[range-parser] new definitions, version 1.2
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// Type definitions for range-parser 1.2
|
||||
// Project: https://github.com/jshttp/range-parser
|
||||
// Definitions by: Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function RangeParser(size: number, str: string, options?: RangeParser.Options): RangeParser.Result | RangeParser.Ranges;
|
||||
|
||||
declare namespace RangeParser {
|
||||
export interface Ranges extends Array<Range> {
|
||||
type: string;
|
||||
}
|
||||
export interface Range {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
export interface Options {
|
||||
combine?: boolean;
|
||||
}
|
||||
export const enum Result {
|
||||
invaild = -2,
|
||||
unsatisifiable = -1,
|
||||
}
|
||||
}
|
||||
|
||||
export = RangeParser;
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as RangeParser from 'range-parser';
|
||||
|
||||
console.assert(RangeParser(200, `malformed`) === RangeParser.Result.invaild);
|
||||
console.assert(RangeParser(200, `bytes=500-20`) === RangeParser.Result.unsatisifiable);
|
||||
|
||||
const range = RangeParser(1000, `bytes=0-499`);
|
||||
|
||||
if (typeof range !== 'number') {
|
||||
console.assert(range.type === `bytes`);
|
||||
console.assert(range.length === 1);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"range-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user