Merge pull request #13034 from screendriver/http-link-header

Added http-link-header
This commit is contained in:
Andy
2017-01-06 06:21:48 -08:00
committed by GitHub
4 changed files with 67 additions and 0 deletions
@@ -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);
+18
View File
@@ -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;
+20
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }