-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
9,149 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mimeData = require("../mime.json"); | ||
exports.getMime = exports.getData = void 0; | ||
let mimeData = require('../mime.json'); | ||
function getData(path) { | ||
var lio = path.lastIndexOf("."); | ||
var ext = (lio === -1 ? path : path.slice(lio + 1)).toLowerCase(); | ||
let lio = path.lastIndexOf('.'); | ||
let ext = (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, | ||
"extension": ext | ||
'mime': "application/octet-stream", | ||
'compressible': false, | ||
'extension': ext | ||
}; | ||
} | ||
} | ||
exports.getData = getData; | ||
function getMime(path) { | ||
return getData(path)["mime"]; | ||
return getData(path)['mime']; | ||
} | ||
exports.getMime = getMime; | ||
//# sourceMappingURL=index.js.map |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# mime.js | ||
|
||
<p align="center"> | ||
<a href="https://github.com/litert/mime.js/blob/master/LICENSE"> | ||
<img alt="License" src="https://img.shields.io/github/license/litert/mime.js?color=blue" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@litert/mime"> | ||
<img alt="NPM stable version" src="https://img.shields.io/npm/v/@litert/mime?color=brightgreen&logo=npm" /> | ||
</a><br> | ||
<a href="https://github.com/litert/mime.js/releases"> | ||
<img alt="GitHub releases" src="https://img.shields.io/github/v/release/litert/mime.js?color=brightgreen&logo=github" /> | ||
</a> | ||
<a href="https://github.com/litert/mime.js/issues"> | ||
<img alt="GitHub issues" src="https://img.shields.io/github/issues/litert/mime.js?color=blue&logo=github" /> | ||
</a> | ||
</p> | ||
|
||
ファイル名、パス、拡張子から mime タイプを取得します。 | ||
|
||
> このライブラリは頻繁に更新する必要がないため、長い間更新されていなくても、存在している限り使用可能です。私たちは常に最新の Node およびブラウザ環境で正常に動作するかどうかを確認しています。 | ||
## インストール | ||
|
||
### NPM | ||
|
||
次の npm コマンドを使用して直接インストールできます。 | ||
|
||
```sh | ||
$ npm i @litert/mime --save | ||
``` | ||
|
||
### CDN | ||
|
||
ブラウザで使用する場合は、CDN モードを使用できます: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.0/dist/loader.min.js?path=index&npm={'@litert/mime':'0.1.2'}"></script> | ||
``` | ||
|
||
## 使用 | ||
|
||
デモコードは TypeScript で記述されています。 | ||
|
||
```typescript | ||
import * as mime from "@litert/mime"; | ||
|
||
mime.getData("hello.json"); // {"mime": "application/json", "compressible": true, extension: 'json'} | ||
mime.getData(".html"); // {"mime": "text/html", "compressible": true, extension: 'html'} | ||
mime.getData("css"); // {"mime": "text/css", "compressible": true, extension: 'css'} | ||
mime.getData("hi/baby.js"); // {"mime": "application/javascript", "compressible": true, extension: 'js'} | ||
mime.getData("/root/down/pk.zip"); // {"mime": "application/zip", "compressible": false, extension: 'zip'} | ||
mime.getData("ext.dodooh"); // {"mime": "application/octet-stream", "compressible": false, extension: 'dodooh'} | ||
mime.getMime("root/index.css"); // text/css | ||
``` | ||
|
||
## サンプル | ||
|
||
### Node | ||
|
||
コンパイル後に、ターミナルで `node ./dist/test-node` を使用してサンプルコードを実行できます。 | ||
|
||
### ブラウザ | ||
|
||
`test/` ディレクトリにアクセスすると、サンプルを表示できます。 | ||
|
||
[ここをクリックしてオンラインでサンプルを表示](https://litert.github.io/mime.js/test/) | ||
|
||
## ライセンス | ||
|
||
このライブラリは [Apache-2.0](../LICENSE) ライセンスで提供されています。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# mime.js | ||
|
||
<p align="center"> | ||
<a href="https://github.com/litert/mime.js/blob/master/LICENSE"> | ||
<img alt="License" src="https://img.shields.io/github/license/litert/mime.js?color=blue" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@litert/mime"> | ||
<img alt="NPM stable version" src="https://img.shields.io/npm/v/@litert/mime?color=brightgreen&logo=npm" /> | ||
</a><br> | ||
<a href="https://github.com/litert/mime.js/releases"> | ||
<img alt="GitHub releases" src="https://img.shields.io/github/v/release/litert/mime.js?color=brightgreen&logo=github" /> | ||
</a> | ||
<a href="https://github.com/litert/mime.js/issues"> | ||
<img alt="GitHub issues" src="https://img.shields.io/github/issues/litert/mime.js?color=blue&logo=github" /> | ||
</a> | ||
</p> | ||
|
||
根据文件名、路径、扩展名获取 mime 类型。 | ||
|
||
> 本库不需要经常更新,因此即使很久没有更新,只要它依然存在,则表示他是可用的。我们会持续关注其是否可以正常运行在最新的 Node 和浏览器环境。 | ||
## 安装 | ||
|
||
### NPM | ||
|
||
你可以直接通过 npm 命令进行安装。 | ||
|
||
```sh | ||
$ npm i @litert/mime --save | ||
``` | ||
|
||
### CDN | ||
|
||
如果你在浏览器中使用,可以使用 CDN 模式: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.0/dist/loader.min.js?path=index&npm={'@litert/mime':'0.1.2'}"></script> | ||
``` | ||
|
||
## 使用 | ||
|
||
演示代码使用 Typescript 语言编写。 | ||
|
||
```typescript | ||
import * as mime from "@litert/mime"; | ||
|
||
mime.getData("hello.json"); // {"mime": "application/json", "compressible": true, extension: 'json'} | ||
mime.getData(".html"); // {"mime": "text/html", "compressible": true, extension: 'html'} | ||
mime.getData("css"); // {"mime": "text/css", "compressible": true, extension: 'css'} | ||
mime.getData("hi/baby.js"); // {"mime": "application/javascript", "compressible": true, extension: 'js'} | ||
mime.getData("/root/down/pk.zip"); // {"mime": "application/zip", "compressible": false, extension: 'zip'} | ||
mime.getData("ext.dodooh"); // {"mime": "application/octet-stream", "compressible": false, extension: 'dodooh'} | ||
mime.getMime("root/index.css"); // text/css | ||
``` | ||
|
||
## 示例 | ||
|
||
### Node | ||
|
||
正确编译后,在终端中使用 `node ./dist/test-node` 就可以运行示例代码。 | ||
|
||
### 浏览器 | ||
|
||
在浏览器中访问 `test/` 目录即可查看示例。 | ||
|
||
[点击此处在线查看示例](https://litert.github.io/mime.js/test/) | ||
|
||
## 许可 | ||
|
||
本库使用 [Apache-2.0](../LICENSE) 许可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# mime.js | ||
|
||
<p align="center"> | ||
<a href="https://github.com/litert/mime.js/blob/master/LICENSE"> | ||
<img alt="License" src="https://img.shields.io/github/license/litert/mime.js?color=blue" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@litert/mime"> | ||
<img alt="NPM stable version" src="https://img.shields.io/npm/v/@litert/mime?color=brightgreen&logo=npm" /> | ||
</a><br> | ||
<a href="https://github.com/litert/mime.js/releases"> | ||
<img alt="GitHub releases" src="https://img.shields.io/github/v/release/litert/mime.js?color=brightgreen&logo=github" /> | ||
</a> | ||
<a href="https://github.com/litert/mime.js/issues"> | ||
<img alt="GitHub issues" src="https://img.shields.io/github/issues/litert/mime.js?color=blue&logo=github" /> | ||
</a> | ||
</p> | ||
|
||
根據檔案名稱、路徑和副檔名獲取 mime 類型。 | ||
|
||
> 本庫不需要經常更新,因此即使很久沒有更新,只要它依然存在,則表示它是可用的。我們會持續關注其是否可以正常運行在最新的 Node 和瀏覽器環境。 | ||
## 安裝 | ||
|
||
### NPM | ||
|
||
你可以直接通過 npm 命令進行安裝。 | ||
|
||
```sh | ||
$ npm i @litert/mime --save | ||
``` | ||
|
||
### CDN | ||
|
||
如果你在瀏覽器中使用,可以使用 CDN 模式: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.0/dist/loader.min.js?path=index&npm={'@litert/mime':'0.1.2'}"></script> | ||
``` | ||
|
||
## 使用 | ||
|
||
演示程式碼使用 TypeScript 語言編寫。 | ||
|
||
```typescript | ||
import * as mime from "@litert/mime"; | ||
|
||
mime.getData("hello.json"); // {"mime": "application/json", "compressible": true, extension: 'json'} | ||
mime.getData(".html"); // {"mime": "text/html", "compressible": true, extension: 'html'} | ||
mime.getData("css"); // {"mime": "text/css", "compressible": true, extension: 'css'} | ||
mime.getData("hi/baby.js"); // {"mime": "application/javascript", "compressible": true, extension: 'js'} | ||
mime.getData("/root/down/pk.zip"); // {"mime": "application/zip", "compressible": false, extension: 'zip'} | ||
mime.getData("ext.dodooh"); // {"mime": "application/octet-stream", "compressible": false, extension: 'dodooh'} | ||
mime.getMime("root/index.css"); // text/css | ||
``` | ||
|
||
## 示例 | ||
|
||
### Node | ||
|
||
正確編譯後,在終端中使用 `node ./dist/test-node` 就可以執行示例程式碼。 | ||
|
||
### 瀏覽器 | ||
|
||
在瀏覽器中訪問 `test/` 目錄即可查看示例。 | ||
|
||
[點擊此處在線查看示例](https://litert.github.io/mime.js/test/) | ||
|
||
## 許可 | ||
|
||
本庫使用 [Apache-2.0](../LICENSE) 許可。 |
Oops, something went wrong.