From df625c8fa7672ca47332d0c1a98b8ec7038114b2 Mon Sep 17 00:00:00 2001 From: Openbyte Date: Fri, 16 Feb 2018 15:35:05 +0100 Subject: [PATCH] Added declarations for 'urlparser' --- types/urlparser/index.d.ts | 38 ++++++++++++++++++++++++++++++ types/urlparser/tsconfig.json | 24 +++++++++++++++++++ types/urlparser/tslint.json | 3 +++ types/urlparser/urlparser-tests.ts | 8 +++++++ 4 files changed, 73 insertions(+) create mode 100644 types/urlparser/index.d.ts create mode 100644 types/urlparser/tsconfig.json create mode 100644 types/urlparser/tslint.json create mode 100644 types/urlparser/urlparser-tests.ts diff --git a/types/urlparser/index.d.ts b/types/urlparser/index.d.ts new file mode 100644 index 0000000000..4c63a74d4a --- /dev/null +++ b/types/urlparser/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for urlparser 0.2 +// Project: https://github.com/kaerus-component/urlparser +// Definitions by: OpenByteDev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// TypeScript Version: 2.2 + +interface UrlData { + host: { + protocol: string; + username: string; + password: string; + hostname: string; + port: string|number; + }; + path: { + base: string; + name: string; + hash: string; + }; + query: { + parts: string[]; + params: object; + }; + toString: () => string; +} + +interface UrlParser { + url: (o: UrlData|undefined) => string; + host: (o: UrlData|undefined) => string; + path: (o: UrlData|undefined) => string; + query: (o: UrlData|undefined) => string; + parse: (parse: string) => UrlData; +} + +declare const urlParser: UrlParser; + +export = urlParser; diff --git a/types/urlparser/tsconfig.json b/types/urlparser/tsconfig.json new file mode 100644 index 0000000000..6822cfc4f8 --- /dev/null +++ b/types/urlparser/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "urlparser-tests.ts" + ] +} \ No newline at end of file diff --git a/types/urlparser/tslint.json b/types/urlparser/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/urlparser/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/urlparser/urlparser-tests.ts b/types/urlparser/urlparser-tests.ts new file mode 100644 index 0000000000..9f632f5207 --- /dev/null +++ b/types/urlparser/urlparser-tests.ts @@ -0,0 +1,8 @@ +import url = require('urlparser'); + +const u = url.parse('http://user:pass@kaerus.com/login?x=42'); +u.host.hostname = 'database.kaerus.com'; +u.host.password = 'secret'; +u.host.port = 8529; +u.query.parts.push('a=13'); +u.toString();