Skip to content

Commit

Permalink
feat(api/mime): introduce MIME database
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Nov 9, 2023
1 parent 5ef69b3 commit 76ac350
Show file tree
Hide file tree
Showing 12 changed files with 2,306 additions and 0 deletions.
65 changes: 65 additions & 0 deletions api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4911,6 +4911,71 @@ declare module "socket:i18n" {
export default _default;
import Enumeration from "socket:enumeration";
}
declare module "socket:mime/index" {
/**
* Look up a MIME type in various MIME databases.
* @return {Promise<Array<{ name: string, mime: string }>>}
*/
export function lookup(query: any): Promise<Array<{
name: string;
mime: string;
}>>;
/**
* A container for MIME types by class (audio, video, text, etc)
* @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml}
*/
export class Database {
/**
* `Database` class constructor.
* @param {string} name
*/
constructor(name: string);
/**
* @type {string}
*/
name: string;
/**
* @type {URL}
*/
url: URL;
/**
* @type {Map}
*/
map: Map<any, any>;
/**
* Loads database MIME entries into internal map.
* @return {Promise}
*/
load(): Promise<any>;
/**
* Lookup MIME type by name.
* @param {string} query
* @return {Promise<{ name: string, mime: string}>}
*/
lookup(query: string): Promise<{
name: string;
mime: string;
}>;
}
export const application: Database;
export const audio: Database;
export const font: Database;
export const image: Database;
export const model: Database;
export const multipart: Database;
export const text: Database;
export const video: Database;
namespace _default {
export { application };
export { Database };
}
export default _default;
}
declare module "socket:mime" {
export * from "socket:mime/index";
export default exports;
import * as exports from "socket:mime/index";
}
declare module "socket:test/fast-deep-equal" {
export default function equal(a: any, b: any): boolean;
}
Expand Down
8 changes: 8 additions & 0 deletions api/mime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module mime
* @notice This is a rexports of `mime/index.js` so consumers will
* need to only `import mime from 'socket:mime'`
*/
import * as exports from './mime/index.js'
export * from './mime/index.js'
export default exports
Loading

0 comments on commit 76ac350

Please sign in to comment.