Added http-link-header

This commit is contained in:
Christian Rackerseder
2016-12-01 08:19:27 +01:00
parent 5c2fa5ca0e
commit 2e1a28de3d
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);
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for http-link-header v0.6.0
// 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: Array<Reference>;
has: (attribute: string, value: string) => boolean;
get: (attribute: string, value: string) => Reference;
rel: (value: string) => Reference;
set: (ref: Reference) => Reference;
toString: () => string;
}
export function parse(header: string): Link;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"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" }