diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/cache-content-type | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/cache-content-type')
| -rw-r--r-- | node_modules/cache-content-type/History.md | 15 | ||||
| -rw-r--r-- | node_modules/cache-content-type/README.md | 17 | ||||
| -rw-r--r-- | node_modules/cache-content-type/index.js | 15 | ||||
| -rw-r--r-- | node_modules/cache-content-type/package.json | 42 |
4 files changed, 89 insertions, 0 deletions
diff --git a/node_modules/cache-content-type/History.md b/node_modules/cache-content-type/History.md new file mode 100644 index 00000000..b75e577a --- /dev/null +++ b/node_modules/cache-content-type/History.md @@ -0,0 +1,15 @@ + +1.0.1 / 2018-07-18 +================== + +**others** + * [[`88c57c0`](http://github.com/node-modules/cache-content-type/commit/88c57c0bd571da12d7917ae15ad67f02b7b5eabe)] - chore: support node 6 (dead-horse <<dead_horse@qq.com>>) + +1.0.0 / 2018-07-11 +================== + +**features** + * [[`ecb6476`](http://github.com/node-modules/cache-content-type/commit/ecb6476da4a714246f12a86c191dc05aad42e806)] - feat: cache result of mimeTypes.contentType (dead-horse <<dead_horse@qq.com>>),fatal: No names found, cannot describe anything. + +**others** + diff --git a/node_modules/cache-content-type/README.md b/node_modules/cache-content-type/README.md new file mode 100644 index 00000000..605d6c44 --- /dev/null +++ b/node_modules/cache-content-type/README.md @@ -0,0 +1,17 @@ +## cache-content-type + +The same as [mime-types](https://github.com/jshttp/mime-types)'s contentType method, but with result cached. + +### Install + +```bash +npm i cache-content-type +``` + +### Usage + +```js +const getType = require('cache-content-type'); +const contentType = getType('html'); +assert(contentType === 'text/html; charset=utf-8'); +``` diff --git a/node_modules/cache-content-type/index.js b/node_modules/cache-content-type/index.js new file mode 100644 index 00000000..60e66671 --- /dev/null +++ b/node_modules/cache-content-type/index.js @@ -0,0 +1,15 @@ +'use strict'; + +const mimeTypes = require('mime-types'); +const LRU = require('ylru'); + +const typeLRUCache = new LRU(100); + +module.exports = type => { + let mimeType = typeLRUCache.get(type); + if (!mimeType) { + mimeType = mimeTypes.contentType(type); + typeLRUCache.set(type, mimeType); + } + return mimeType; +}; diff --git a/node_modules/cache-content-type/package.json b/node_modules/cache-content-type/package.json new file mode 100644 index 00000000..d3f0c76f --- /dev/null +++ b/node_modules/cache-content-type/package.json @@ -0,0 +1,42 @@ +{ + "name": "cache-content-type", + "version": "1.0.1", + "description": "Create a full Content-Type header given a MIME type or extension and catch the result", + "main": "index.js", + "files": [ + "index.js" + ], + "scripts": { + "test": "egg-bin test", + "cov": "egg-bin cov", + "ci": "eslint . && npm run cov" + }, + "dependencies": { + "mime-types": "^2.1.18", + "ylru": "^1.2.0" + }, + "devDependencies": { + "egg-bin": "^4.7.1", + "egg-ci": "^1.8.0", + "eslint": "^5.1.0", + "eslint-config-egg": "^7.0.0", + "mm": "^2.2.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/node-modules/cache-content-type.git" + }, + "keywords": [ + "mime", + "content-type", + "lru" + ], + "engines": { + "node": ">= 6.0.0" + }, + "ci": { + "version": "6, 8, 10" + }, + "author": "dead_horse", + "license": "MIT" +} |
