diff --git a/types/protocols/index.d.ts b/types/protocols/index.d.ts new file mode 100644 index 0000000000..3812b71280 --- /dev/null +++ b/types/protocols/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for protocols 1.4 +// Project: https://github.com/IonicaBizau/protocols +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * @param input The input url. + * @param first If `true`, the first protocol will be returned. If number, it will represent the zero-based index of the protocols array. + * @returns The array of protocols or the specified protocol. + */ +declare function protocols(input: string, first: true | number): string; +declare function protocols(input: string, first?: false): string[]; + +export = protocols; diff --git a/types/protocols/protocols-tests.ts b/types/protocols/protocols-tests.ts new file mode 100644 index 0000000000..abf6ad1e9a --- /dev/null +++ b/types/protocols/protocols-tests.ts @@ -0,0 +1,6 @@ +import protocols = require('protocols'); + +protocols('git+ssh://git@some-host.com/and-the-path/name'); // $ExpectType string[] +protocols('http://example.com', true); // $ExpectType string +protocols('ftp://example.com', 1); // $ExpectType string +protocols('https://example.com', false); // $ExpectType string[] diff --git a/types/protocols/tsconfig.json b/types/protocols/tsconfig.json new file mode 100644 index 0000000000..2d3258b26a --- /dev/null +++ b/types/protocols/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "protocols-tests.ts" + ] +} diff --git a/types/protocols/tslint.json b/types/protocols/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/protocols/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }