Skip to content

Commit

Permalink
v0.1.1 - Add extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunbookf committed Mar 19, 2020
1 parent 0f88348 commit aebba19
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IData {
export interface IDataItem {
"mime": string;
"compressible": boolean;
"extension": string;
}
export declare function getData(path: string): IDataItem;
export declare function getMime(path: string): string;
4 changes: 3 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@litert/mime",
"version": "0.1.0",
"version": "0.1.1",
"description": "Get MIME type based on file name.",
"keywords": [
"litert",
"mime"
"mime",
"extension"
],
"main": "./dist/index.js",
"author": "hanguoshuai",
Expand Down
9 changes: 6 additions & 3 deletions sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export interface IData {
}

export interface IDataItem {
"mime": string,
"compressible": boolean
"mime": string;
"compressible": boolean;
"extension": string;
}

let mimeData: IData = require("../mime.json");
Expand All @@ -20,11 +21,13 @@ export function getData(path: string): IDataItem {
let lio = path.lastIndexOf(".");
let ext: string = (lio === -1 ? path : path.slice(lio + 1)).toLowerCase();
if (mimeData[ext]) {
mimeData[ext].extension = ext;
return mimeData[ext];
} else {
return {
"mime": "application/octet-stream",
"compressible": false
"compressible": false,
"extension": ext
};
}
}
Expand Down

0 comments on commit aebba19

Please sign in to comment.