mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Add whatwg-mimetype definition.
This commit is contained in:
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for whatwg-mimetype 2.1
|
||||
// Project: https://github.com/jsdom/whatwg-mimetype#readme
|
||||
// Definitions by: Pete Johanson <https://github.com/petejohanson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = MIMEType;
|
||||
|
||||
declare class MIMEType {
|
||||
type: string;
|
||||
subtype: string;
|
||||
|
||||
readonly essence: string;
|
||||
readonly parameters: Map<string, string>;
|
||||
|
||||
static parse(s: string): MIMEType | null;
|
||||
|
||||
constructor(s: string);
|
||||
|
||||
isHTML(): boolean;
|
||||
isXML(): boolean;
|
||||
isJavaScript(opts?: { allowParameters?: boolean }): boolean;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"whatwg-mimetype-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference types="node" />
|
||||
import assert = require("assert");
|
||||
import MIMEType = require('whatwg-mimetype');
|
||||
|
||||
const mt = MIMEType.parse("text/plain");
|
||||
|
||||
assert(mt !== null);
|
||||
if (mt) {
|
||||
assert(mt.type === "text");
|
||||
assert(mt.subtype === "plain");
|
||||
assert(mt.essence === "text/plain");
|
||||
assert(mt.parameters.size === 0);
|
||||
assert(!mt.isXML());
|
||||
assert(!mt.isHTML());
|
||||
assert(!mt.isJavaScript());
|
||||
}
|
||||
|
||||
const mt2 = new MIMEType("application/javascript; charset=utf8");
|
||||
|
||||
assert(mt2.type === "text");
|
||||
assert(mt2.subtype === "plain");
|
||||
assert(mt2.essence === "text/plain");
|
||||
assert(mt2.parameters.get("charset") === "utf8");
|
||||
assert(mt2.isJavaScript({ allowParameters: true }));
|
||||
Reference in New Issue
Block a user