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..f72a1fe065 --- /dev/null +++ b/http-link-header/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Reference { + uri: string; + rel: string; + title?: string; +} +export interface Link { + refs: Array; + 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; diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json new file mode 100644 index 0000000000..12f90f78bd --- /dev/null +++ b/http-link-header/tsconfig.json @@ -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" + ] +} 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" }