diff --git a/types/ale-url-parser/ale-url-parser-tests.ts b/types/ale-url-parser/ale-url-parser-tests.ts new file mode 100644 index 0000000000..2a5d9fe632 --- /dev/null +++ b/types/ale-url-parser/ale-url-parser-tests.ts @@ -0,0 +1,22 @@ +import { parse, stringify } from 'ale-url-parser'; + +let url; +let urlObject; + +url = stringify({}); +console.log(url); + +url = stringify({ + protocol: 'protocol', + host: 'host', + path: ['foo', 'bar', 'baz'], + hash: 'hash', + query: { + foo: 1, + bar: [2, '3'] + } +}); +console.log(url); + +urlObject = parse('//any.dom.ain.co.m/foo/bar?test=1&test=2#hash'); +console.log(urlObject); diff --git a/types/ale-url-parser/index.d.ts b/types/ale-url-parser/index.d.ts new file mode 100644 index 0000000000..31b2d2fd03 --- /dev/null +++ b/types/ale-url-parser/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for ale-url-parser 0.10 +// Project: https://github.com/msn0/ale-url-parser#readme +// Definitions by: MichaƂ Jezierski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export interface QueryParams { + [key: string]: any; +} + +export interface UrlObject { + protocol?: string; + host?: string; + path?: string[]; + query?: QueryParams; + hash?: string; +} + +/** + * Parse url string into url object. + * @return UrlObject + */ +export function parse(url: string): UrlObject; + +/** + * Stringify url object into url string. + * @return string + */ +export function stringify(urlObject: UrlObject): string; diff --git a/types/ale-url-parser/tsconfig.json b/types/ale-url-parser/tsconfig.json new file mode 100644 index 0000000000..2d18200901 --- /dev/null +++ b/types/ale-url-parser/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ale-url-parser-tests.ts" + ] +} diff --git a/types/ale-url-parser/tslint.json b/types/ale-url-parser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ale-url-parser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }