Comparing version 0.0.2 to 0.0.3
@@ -0,1 +1,6 @@ | ||
## [0.0.3](https://github.com/nqdy666/nq-cache/compare/v0.0.2...v0.0.3) (2019-03-22) | ||
## 0.0.2 (2019-03-21) | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "nq-cache", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "function cache", | ||
@@ -11,2 +11,3 @@ "main": "lib/index.js", | ||
"files": [ | ||
"src", | ||
"lib", | ||
@@ -33,6 +34,6 @@ "dist", | ||
"test:unit": "jest --no-cache", | ||
"test:e2e": "npm run build && node test/e2e/runner.js", | ||
"test:e2e": "node test/e2e/runner.js", | ||
"test:e2e:sauce": "npm run test:e2e -- --env chrome,firefox,ie11,ie10,ie9,ie8,edge,safari,iphone6,android4.4", | ||
"test": "npm run test:unit && npm run test:e2e -- --env phantomjs", | ||
"example": "serve ./examples", | ||
"test": "npm run test:unit && npm run test:e2e -- --env chrome", | ||
"example": "serve", | ||
"flow": "flow", | ||
@@ -106,5 +107,4 @@ "prelint": "npm run flow", | ||
"jest-localstorage-mock": "^2.2.0", | ||
"nightwatch": "^1.0.19", | ||
"nightwatch": "^0.9.21", | ||
"nightwatch-helpers": "^1.2.0", | ||
"phantomjs-prebuilt": "^2.1.16", | ||
"rollup": "^1.7.0", | ||
@@ -111,0 +111,0 @@ "rollup-plugin-alias": "^1.4.0", |
104
README.md
NQ-CACHE | ||
> 函数缓存 | ||
> function cache | ||
@@ -11,17 +11,12 @@ [![build status](https://api.travis-ci.org/nqdy666/nq-cache.svg?branch=master)](https://travis-ci.org/nqdy666/nq-cache) | ||
[![Build Status](https://saucelabs.com/browser-matrix/nqdy666.svg)](https://saucelabs.com/beta/builds/1997be72b34e41228522a3a3e065d993) | ||
## 特性 | ||
## Features | ||
- IE8+ | ||
- 支持Typescript | ||
- 支持纯函数缓存 | ||
- 支持返回值Promise的函数缓存 | ||
- 支持缓存到sessionStorage | ||
- Support for Typescript | ||
## 文档 | ||
- [Example on JSBin](https://jsbin.com/baluray/edit?html,js,output) | ||
## Document | ||
- [Example on JSBin] (https://jsbin.com/baluray/edit?html,js,output) | ||
## 安装 | ||
## Installation | ||
安装npm包 | ||
Install npm package | ||
@@ -32,3 +27,3 @@ ```bash | ||
使用 `pureFuncMemoryCache` | ||
Use `pureFuncMemoryCache` | ||
@@ -40,3 +35,3 @@ add.js | ||
export function add (a, b) { | ||
return a + b | ||
return a + b | ||
} | ||
@@ -50,7 +45,7 @@ | ||
import { addCache as add } from './add' | ||
add(1, 2) // 执行,并把结果缓存 | ||
add(1, 2) // 直接从缓存中获取结果 | ||
add(1, 2) // execute and cache the result | ||
add(1, 2) // Get results directly from the cache | ||
``` | ||
使用 `promiseMemoryCache` | ||
use `promiseMemoryCache` | ||
@@ -75,10 +70,10 @@ request.js | ||
import { requestCache as request } from './request' | ||
// 执行,并把结果缓存 | ||
// execute and cache the result | ||
request({ name: 'bowl' }).then(res => { | ||
// 直接从缓存中获取结果 | ||
return request({ name: 'bowl' }) | ||
// get results directly from the cache | ||
return request({ name: 'bowl' }) | ||
}) | ||
``` | ||
使用 `promiseSessionStorageCache` | ||
use `promiseSessionStorageCache` | ||
@@ -103,6 +98,6 @@ request.js | ||
import { requestCache as request } from './request' | ||
// 执行,并把结果缓存 | ||
// execute and cache the result | ||
request({ name: 'bowl' }).then(res => { | ||
// 直接从缓存中获取结果 | ||
return request({ name: 'bowl' }) | ||
// Get results directly from the cache | ||
return request({ name: 'bowl' }) | ||
}) | ||
@@ -113,33 +108,40 @@ ``` | ||
仅包含 `nq-cache` | ||
Contains only `nq-cache` | ||
```html | ||
<!-- 使用最新版本 --> | ||
<!-- Use the latest version --> | ||
<script src="https://unpkg.com/nq-cache@latest"></script> | ||
<!-- 或指定某一个版本 --> | ||
<script src="https://unpkg.com/nq-cache@0.0.2"></script> | ||
<!-- or specify a version --> | ||
<script src="https://unpkg.com/nq-cache@0.0.3"></script> | ||
<script> | ||
function add (a, b) { | ||
return a + b | ||
} | ||
addCache = cache.pureFuncMemoryCache(add) | ||
addCache(1, 2) // 执行,并把结果缓存 | ||
addCache(1, 2) // 直接从缓存中获取结果 | ||
function add (a, b) { | ||
return a + b | ||
} | ||
addCache = cache.pureFuncMemoryCache(add) | ||
addCache(1, 2) // Execute and cache the result | ||
addCache(1, 2) // Get the result directly from the cache | ||
</script> | ||
``` | ||
其他更多的方法,可以查看[例子](https://jsbin.com/baluray/edit?html,js,output) | ||
For more other methods, you can view [example] (https://jsbin.com/baluray/edit?html,js,output) | ||
提示,如果浏览器不支持 Promise 或者 JSON,你应该进行 polyfill | ||
if the browser does not support Promise or JSON, you should do a polyfill | ||
```html | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script> | ||
<!--[if lt IE 8]> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/json2/20160511/json2.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/json2/20160511/json2.min.js"></script> | ||
<![endif]--> | ||
``` | ||
## 本地开发 | ||
### Methods | ||
- pureFuncMemoryCache | ||
- promiseMemoryCache | ||
- promiseSessionStorageCache | ||
- clearCache | ||
- argToKey | ||
- 安装依赖 | ||
## Local development | ||
- Installation dependencies | ||
```bash | ||
@@ -149,3 +151,3 @@ npm install | ||
- 测试 | ||
- Testing | ||
@@ -156,3 +158,3 @@ ```bash | ||
- 打包 | ||
- Build | ||
@@ -175,3 +177,3 @@ ```bash | ||
- 更新文档 | ||
- Update documentation | ||
@@ -181,1 +183,19 @@ ```bash | ||
``` | ||
- Run the test page | ||
```bash | ||
npm run build | ||
npm run example | ||
Then open it with a browser | ||
Http://localhost:5000/examples/ | ||
``` | ||
- Release | ||
```bash | ||
npm version [new version] | ||
npm run build | ||
npm publish | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59299
64
31
685
191