[content-range] Adding types for content-range module

This commit is contained in:
Alex Brick 2019-01-31 12:47:22 +01:00
parent ff975a6dc5
commit 2bcbb3d221
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import { format, parse } from 'content-range';
format({
first: 10,
last: 100,
length: 100,
limit: 20,
unit: 'items',
});
format({
length: null,
unit: 'bytes',
});
const parts = parse('items 10-29/100');
if (parts) {
parts.first;
parts.last;
parts.length;
parts.unit;
}

22
types/content-range/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for content-range 1.1
// Project: https://github.com/neoziro/content-range
// Definitions by: Alex Brick <https://github.com/bricka>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ContentRangeFormatOptions {
first?: number;
last?: number;
length: number | null;
limit?: number;
unit: string;
}
export interface ContentRangeParts {
first: number | null;
last: number | null;
length: number | null;
unit: string;
}
export function format(options: ContentRangeFormatOptions): string;
export function parse(str: string): ContentRangeParts | null;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"content-range-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }