diff --git a/range-parser/index.d.ts b/range-parser/index.d.ts new file mode 100644 index 0000000000..e90f448e11 --- /dev/null +++ b/range-parser/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for range-parser 1.2 +// Project: https://github.com/jshttp/range-parser +// Definitions by: Tomek Łaziuk +// 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 { + type: string; + } + export interface Range { + start: number; + end: number; + } + export interface Options { + combine?: boolean; + } + export const enum Result { + invaild = -2, + unsatisifiable = -1, + } +} + +export = RangeParser; diff --git a/range-parser/range-parser-tests.ts b/range-parser/range-parser-tests.ts new file mode 100644 index 0000000000..77dab456c1 --- /dev/null +++ b/range-parser/range-parser-tests.ts @@ -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); +} diff --git a/range-parser/tsconfig.json b/range-parser/tsconfig.json new file mode 100644 index 0000000000..7c7f4ffd03 --- /dev/null +++ b/range-parser/tsconfig.json @@ -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" + ] +} diff --git a/range-parser/tslint.json b/range-parser/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/range-parser/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }