mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { TypeMap } from "./index";
|
||||
|
||||
export default class Mime {
|
||||
constructor(mimes: TypeMap);
|
||||
|
||||
getType(path: string): string | null;
|
||||
getExtension(mime: string): string | null;
|
||||
define(mimes: TypeMap, force?: boolean): void;
|
||||
}
|
||||
Vendored
+7
-10
@@ -1,20 +1,17 @@
|
||||
// Type definitions for mime 1.3
|
||||
// Type definitions for mime 2.0
|
||||
// Project: https://github.com/broofa/node-mime
|
||||
// Definitions by: Jeff Goddard <https://github.com/jedigo>
|
||||
// Daniel Hritzkiv <https://github.com/dhritzkiv>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
|
||||
// Originally imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
|
||||
|
||||
export as namespace mime;
|
||||
|
||||
export function lookup(path: string, fallback?: string): string;
|
||||
export function extension(mime: string): string;
|
||||
export function load(filepath: string): void;
|
||||
export function define(mimes: { [key: string]: any }): void;
|
||||
export interface TypeMap { [key: string]: string[]; }
|
||||
|
||||
export interface Charsets {
|
||||
lookup(mime: string): string;
|
||||
}
|
||||
export function getType(path: string): string | null;
|
||||
export function getExtension(mime: string): string | null;
|
||||
export function define(mimes: TypeMap, force?: boolean): void;
|
||||
|
||||
export const charsets: Charsets;
|
||||
export const default_type: string;
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import * as mime from "mime";
|
||||
import Mime from "mime/Mime";
|
||||
|
||||
let str: string;
|
||||
const obj: {} = {};
|
||||
const fallback = '';
|
||||
let strOrNul: string | null;
|
||||
|
||||
const obj = {
|
||||
mime: ["ext", "ext2"]
|
||||
};
|
||||
|
||||
const obj2 = {
|
||||
"text/plain": ["txt"]
|
||||
};
|
||||
|
||||
str = mime.lookup(str, fallback);
|
||||
str = mime.extension(str);
|
||||
mime.load(str);
|
||||
mime.define(obj);
|
||||
mime.define(obj2, true);
|
||||
strOrNul = mime.getType("ext");
|
||||
strOrNul = mime.getType("foo");
|
||||
strOrNul = mime.getExtension("mime");
|
||||
strOrNul = mime.getExtension("bar");
|
||||
|
||||
str = mime.charsets.lookup(str);
|
||||
const myMime = new Mime(obj);
|
||||
strOrNul = myMime.getType("foo");
|
||||
strOrNul = myMime.getExtension('text/plan');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"Mime.d.ts",
|
||||
"mime-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ import { Server, version, mime } from 'node-static';
|
||||
|
||||
const server = new Server(__dirname);
|
||||
const pathname = server.resolve('./tsconfig.json');
|
||||
const mimetype = mime.lookup(pathname, '');
|
||||
const mimetype = mime.getType(pathname);
|
||||
const versionNum = version.join('.');
|
||||
console.log(`The node-static server constructed an instance of itself, fetched the mimetype of ${pathname} (${mimetype}), and has a version of ${versionNum}! The package is working.`);
|
||||
|
||||
Reference in New Issue
Block a user