@tinyhttp/accepts
Advanced tools
Comparing version
@@ -1,4 +0,4 @@ | ||
/// <reference types="node" /> | ||
import Negotiator from 'negotiator'; | ||
import { IncomingMessage as I, IncomingHttpHeaders } from 'node:http'; | ||
import { default as Negotiator } from 'negotiator'; | ||
export declare class Accepts { | ||
@@ -5,0 +5,0 @@ headers: IncomingHttpHeaders; |
@@ -0,5 +1,5 @@ | ||
import mime from "mime"; | ||
import Negotiator from "negotiator"; | ||
import mime from "mime"; | ||
const extToMime = (type) => type.indexOf("/") == -1 ? mime.getType(type) : type; | ||
const validMime = (type) => typeof type == "string"; | ||
const extToMime = (type) => type.indexOf("/") === -1 ? mime.getType(type) : type; | ||
const validMime = (type) => typeof type === "string"; | ||
class Accepts { | ||
@@ -22,6 +22,6 @@ constructor(req) { | ||
} | ||
if (!mimeTypes || mimeTypes.length == 0) { | ||
if (!mimeTypes || mimeTypes.length === 0) { | ||
return this.negotiator.mediaTypes(); | ||
} | ||
if (!this.headers["accept"]) { | ||
if (!this.headers.accept) { | ||
return mimeTypes[0]; | ||
@@ -50,3 +50,3 @@ } | ||
} | ||
if (!_encodings || _encodings.length == 0) { | ||
if (!_encodings || _encodings.length === 0) { | ||
return this.negotiator.encodings(); | ||
@@ -72,3 +72,3 @@ } | ||
} | ||
if (!_charsets || _charsets.length == 0) { | ||
if (!_charsets || _charsets.length === 0) { | ||
return this.negotiator.charsets(); | ||
@@ -95,3 +95,3 @@ } | ||
} | ||
if (!_languages || _languages.length == 0) { | ||
if (!_languages || _languages.length === 0) { | ||
return this.negotiator.languages(); | ||
@@ -98,0 +98,0 @@ } |
{ | ||
"name": "@tinyhttp/accepts", | ||
"description": "accepts rewrite in TypeScript", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://tinyhttp.v1rtl.site", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19147
-0.03%159
-0.62%