diff --git a/types/mdurl/decode.d.ts b/types/mdurl/decode.d.ts new file mode 100644 index 0000000000..f45d0854b2 --- /dev/null +++ b/types/mdurl/decode.d.ts @@ -0,0 +1,7 @@ +declare namespace decode { + const defaultChars: string; + const componentChars: string; +} +declare function decode(input: string, exclude?: string): string; + +export = decode; diff --git a/types/mdurl/encode.d.ts b/types/mdurl/encode.d.ts new file mode 100644 index 0000000000..7848d3c85e --- /dev/null +++ b/types/mdurl/encode.d.ts @@ -0,0 +1,7 @@ +declare namespace encode { + const defaultChars: string; + const componentChars: string; +} +declare function encode(str: string, exclude?: string, keepEscaped?: boolean): string; + +export = encode; diff --git a/types/mdurl/format.d.ts b/types/mdurl/format.d.ts new file mode 100644 index 0000000000..2638c76007 --- /dev/null +++ b/types/mdurl/format.d.ts @@ -0,0 +1,5 @@ +import { Url } from './' + +declare function format(url: Url): string; + +export = format; diff --git a/types/mdurl/index.d.ts b/types/mdurl/index.d.ts new file mode 100644 index 0000000000..103ca22940 --- /dev/null +++ b/types/mdurl/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for mdurl 1.0 +// Project: https://github.com/markdown-it/mdurl#readme +// Definitions by: Junyoung Choi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import encode = require('./encode'); +import decode = require('./decode'); +import parse = require('./parse'); +import format = require('./format'); + +export interface Url { + protocol: string; + slashes: string; + auth: string; + port: string; + hostname: string; + hash: string; + search: string; + pathname: string; +} + +export { + encode, + decode, + parse, + format +}; diff --git a/types/mdurl/mdurl-tests.ts b/types/mdurl/mdurl-tests.ts new file mode 100644 index 0000000000..28c1141ef5 --- /dev/null +++ b/types/mdurl/mdurl-tests.ts @@ -0,0 +1,32 @@ +import mdurl = require('mdurl'); +import { Url } from 'mdurl'; + +const encoded: string = mdurl.encode('%%%'); +// return '%25%25%25' + +const decoded: string = mdurl.decode(encoded); +// return '%%%' + +const url: Url = mdurl.parse('HTTP://www.example.com/'); +// return { +// 'protocol': 'HTTP:', +// 'slashes': true, +// 'hostname': 'www.example.com', +// 'pathname': '/' +// } as Url + +const urlStr: string = mdurl.format(url); +// 'HTTP://www.example.com/' + +import encode = require('mdurl/encode'); +import decode = require('mdurl/decode'); +import parse = require('mdurl/parse'); +import format = require('mdurl/format'); + +const encoded2: string = encode('%%%'); + +const decoded2: string = decode(encoded); + +const url2: Url = parse('HTTP://www.example.com/'); + +const urlStr2: string = format(url); diff --git a/types/mdurl/parse.d.ts b/types/mdurl/parse.d.ts new file mode 100644 index 0000000000..cd2c012caa --- /dev/null +++ b/types/mdurl/parse.d.ts @@ -0,0 +1,5 @@ +import { Url } from './' + +declare function parse(input: string, slashesDenoteHost?: boolean): Url; + +export = parse; diff --git a/types/mdurl/tsconfig.json b/types/mdurl/tsconfig.json new file mode 100644 index 0000000000..c00c56ef07 --- /dev/null +++ b/types/mdurl/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "mdurl-tests.ts" + ] +} diff --git a/types/mdurl/tslint.json b/types/mdurl/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mdurl/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }