Added declarations for 'urlparser'

This commit is contained in:
Openbyte
2018-02-16 15:35:05 +01:00
parent eac9f9e343
commit df625c8fa7
4 changed files with 73 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
// Type definitions for urlparser 0.2
// Project: https://github.com/kaerus-component/urlparser
// Definitions by: OpenByteDev <https://github.com/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;
+24
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+8
View File
@@ -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();