mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Merge pull request #13034 from screendriver/http-link-header
Added http-link-header
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import * as LinkHeader from 'http-link-header';
|
||||
|
||||
function isBool(bool: boolean): null {
|
||||
return null;
|
||||
}
|
||||
|
||||
function isReference(ref: LinkHeader.Reference): null {
|
||||
return null;
|
||||
}
|
||||
|
||||
function isString(str: string): null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const link = LinkHeader.parse(
|
||||
'<example.com>; rel="example"; title="Example Website", ' +
|
||||
'<example-01.com>; rel="alternate"; title="Alternate Example Domain"'
|
||||
);
|
||||
const has = link.has('rel', 'alternate');
|
||||
isBool(has);
|
||||
const get = link.get('title', 'Example Website');
|
||||
isReference(get);
|
||||
const rel = link.rel('alternate');
|
||||
isReference(rel);
|
||||
const set = link.set({ rel: 'next', uri: 'http://example.com/next' });
|
||||
isReference(set);
|
||||
const str = link.toString();
|
||||
isString(str);
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for http-link-header 0.6
|
||||
// Project: https://github.com/jhermsmeier/node-http-link-header
|
||||
// Definitions by: Christian Rackerseder <https://www.echooff.de/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Reference {
|
||||
uri: string;
|
||||
rel: string;
|
||||
title?: string;
|
||||
}
|
||||
export interface Link {
|
||||
refs: Reference[];
|
||||
has(attribute: string, value: string): boolean;
|
||||
get(attribute: string, value: string): Reference;
|
||||
rel(value: string): Reference;
|
||||
set(ref: Reference): Reference;
|
||||
}
|
||||
export function parse(header: string): Link;
|
||||
@@ -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",
|
||||
"http-link-header-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user