diff --git a/http-link-header/http-link-header-tests.ts b/http-link-header/http-link-header-tests.ts new file mode 100644 index 0000000000..85145dc8eb --- /dev/null +++ b/http-link-header/http-link-header-tests.ts @@ -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( + '; rel="example"; title="Example Website", ' + + '; 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); diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts new file mode 100644 index 0000000000..ba208d8595 --- /dev/null +++ b/http-link-header/index.d.ts @@ -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 +// 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; diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json new file mode 100644 index 0000000000..9fb6d5e158 --- /dev/null +++ b/http-link-header/tsconfig.json @@ -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" + ] +} diff --git a/http-link-header/tslint.json b/http-link-header/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/http-link-header/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }