Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 7049e03

Browse files
author
dkniazevych
committed
mime module shouldn't care about supported extensions/mime-types by file2html
1 parent 0988224 commit 7049e03

File tree

6 files changed

+12
-37
lines changed

6 files changed

+12
-37
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# file2html
2+
[![Build Status](https://secure.travis-ci.org/file2html/file2html.png?branch=master)](https://travis-ci.org/file2html/file2html)
3+
[![npm](https://img.shields.io/npm/dm/file2html.svg)](https://www.npmjs.com/package/file2html)
4+
[![npm](https://img.shields.io/npm/v/file2html.svg)](https://www.npmjs.com/package/file2html)
5+
[![npm](https://img.shields.io/npm/l/file2html.svg)](https://www.npmjs.com/package/file2html)
6+
[![Coverage Status](https://coveralls.io/repos/github/file2html/file2html/badge.svg?branch=master)](https://coveralls.io/github/file2html/file2html?branch=master)
7+
28
> JS convertor of files to HTML and CSS code
39
410
## Requirements

lib/mime.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
export declare function lookup(filename: string): string;
2-
export declare function isSupportedExtension(extension: string): boolean;
3-
export declare function isSupportedMimeType(mimeType: string): boolean;

lib/mime.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,12 @@ var mimeTypes = {
1111
txt: 'text/plain',
1212
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
1313
fb: 'application/x-fictionbook+xml',
14-
fb2: 'application/x-fictionbook+xml'
14+
fb2: 'application/x-fictionbook+xml',
15+
odt: 'application/vnd.oasis.opendocument.text'
1516
};
1617
function lookup(filename) {
1718
var name = filename.toLowerCase();
1819
var extension = name.split('.').pop();
1920
return mimeTypes[extension];
2021
}
2122
exports.lookup = lookup;
22-
function isSupportedExtension(extension) {
23-
return Boolean(mimeTypes[extension.replace(/^\./, '')]);
24-
}
25-
exports.isSupportedExtension = isSupportedExtension;
26-
function isSupportedMimeType(mimeType) {
27-
for (var extension in mimeTypes) {
28-
if (mimeTypes.hasOwnProperty(extension)) {
29-
if (mimeType === mimeTypes[extension]) {
30-
return true;
31-
}
32-
}
33-
}
34-
return false;
35-
}
36-
exports.isSupportedMimeType = isSupportedMimeType;

lib/text-encoding.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* @param {TextEncoding.TextDecodeOptions} [options]
66
* @returns {string}
77
*/
8-
export declare function decode(content: Uint8Array, encoding?: string, options?: TextEncoding.TextDecodeOptions): string;
8+
export declare function decode(content: Uint8Array, encoding?: string, options?: TextEncoding.TextDecoderOptions): string;
99
export declare function encode(text: string, encoding?: string, options?: TextEncoding.TextEncoderOptions): Uint8Array;

src/mime.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,13 @@ const mimeTypes: {[key: string]: string} = {
99
txt: 'text/plain',
1010
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
1111
fb: 'application/x-fictionbook+xml',
12-
fb2: 'application/x-fictionbook+xml'
12+
fb2: 'application/x-fictionbook+xml',
13+
odt: 'application/vnd.oasis.opendocument.text'
1314
};
1415

1516
export function lookup (filename: string) {
1617
const name: string = filename.toLowerCase();
1718
const extension: string = name.split('.').pop();
1819

1920
return mimeTypes[extension];
20-
}
21-
22-
export function isSupportedExtension (extension: string): boolean {
23-
return Boolean(mimeTypes[extension.replace(/^\./, '')]);
24-
}
25-
26-
export function isSupportedMimeType (mimeType: string): boolean {
27-
for (const extension in mimeTypes) {
28-
if (mimeTypes.hasOwnProperty(extension)) {
29-
if (mimeType === mimeTypes[extension]) {
30-
return true;
31-
}
32-
}
33-
}
34-
35-
return false;
3621
}

src/text-encoding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @param {TextEncoding.TextDecodeOptions} [options]
55
* @returns {string}
66
*/
7-
export function decode (content: Uint8Array, encoding?: string, options?: TextEncoding.TextDecodeOptions): string {
7+
export function decode (content: Uint8Array, encoding?: string, options?: TextEncoding.TextDecoderOptions): string {
88
return new TextDecoder(encoding, options).decode(content);
99
}
1010

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy