mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[content-range] Adding types for content-range module
This commit is contained in:
parent
ff975a6dc5
commit
2bcbb3d221
23
types/content-range/content-range-tests.ts
Normal file
23
types/content-range/content-range-tests.ts
Normal 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
22
types/content-range/index.d.ts
vendored
Normal 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;
|
||||
23
types/content-range/tsconfig.json
Normal file
23
types/content-range/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/content-range/tslint.json
Normal file
1
types/content-range/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user