diff --git a/types/mime-types/index.d.ts b/types/mime-types/index.d.ts new file mode 100644 index 0000000000..7be0867a31 --- /dev/null +++ b/types/mime-types/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for mime-types 2.1 +// Project: https://github.com/jshttp/mime-types#readme +// Definitions by: Gyusun Yeom +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function lookup(filenameOrExt: string): string | false; +export function contentType(filenameOrExt: string): string | false; +export function extension(typeString: string): string | false; +export function charset(typeString: string): string | false; +export const types: {[key: string]: string}; +export const extensions: {[key: string]: string[]}; diff --git a/types/mime-types/mime-types-tests.ts b/types/mime-types/mime-types-tests.ts new file mode 100644 index 0000000000..35b5246831 --- /dev/null +++ b/types/mime-types/mime-types-tests.ts @@ -0,0 +1,18 @@ +import * as mime from 'mime-types'; + +mime.lookup('json'); // 'application/json' +mime.lookup('.md'); // 'text/x-markdown' +mime.lookup('file.html'); // 'text/html' +mime.lookup('folder/file.js'); // 'application/javascript' +mime.lookup('folder/.htaccess'); // false + +mime.lookup('cats'); // false +mime.contentType('markdown'); // 'text/x-markdown; charset=utf-8' +mime.contentType('file.json'); // 'application/json; charset=utf-8' + +// from a full path +mime.contentType('.json'); // 'application/json; charset=utf-8' + +mime.extension('application/octet-stream'); // 'bin' + +mime.charset('text/x-markdown'); // 'UTF-8' diff --git a/types/mime-types/tsconfig.json b/types/mime-types/tsconfig.json new file mode 100644 index 0000000000..015c5a8080 --- /dev/null +++ b/types/mime-types/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mime-types-tests.ts" + ] +} diff --git a/types/mime-types/tslint.json b/types/mime-types/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/types/mime-types/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }