Skip to content

Commit

Permalink
chore: 🤖 v1.14.8
Browse files Browse the repository at this point in the history
  • Loading branch information
haozi committed Mar 12, 2024
1 parent 97f5ed2 commit 1423072
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ An elegant library to solve duplicate and concurrent calls for idempotent functi

English | [简体中文](README.zh-CN.md)

- Demo <https://idmp.vercel.app>
- Demo <https://idmp-ha0z1.vercel.app>

## Usage

Expand Down Expand Up @@ -141,7 +141,7 @@ In React, you can share requests using swr, Provider and more complex state mana
2. Provider: Needs centralized data management. The data center can't perceive which modules will consume the data, need to maintain the data for a long time, and dare not delete it in time
3. Redux: Should focus on state changes and sequences, not data sharing. `idmp` lets you focus more on local state

See [demo](https://idmp.vercel.app) and [source code](https://github.com/ha0z1/idmp/tree/main/demo)
See [demo](https://idmp-ha0z1.vercel.app) and [source code](https://github.com/ha0z1/idmp/tree/main/demo)

So when module A or module B's code is deleted, there is no need to maintain their cache.

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

[English](README.md) | 简体中文

- Demo <https://idmp.vercel.app>
- Demo <https://idmp-ha0z1.vercel.app>

## 使用

Expand Down Expand Up @@ -141,7 +141,7 @@ fetchData2().then(...) // will skip cache
2. Provider 数据共享: 需要一个中心化的数据管理。数据中心无法感知到哪些模块会消费数据,需要长期维护这些数据,而不敢及时删除
3. Redux 等状态管理库:应该专注的是状态的变化和时序,而非共享数据。`idmp` 让你更关注于局部状态

查看 [demo](https://idmp.vercel.app)[源码](https://github.com/ha0z1/idmp/tree/main/demo)
查看 [demo](https://idmp-ha0z1.vercel.app)[源码](https://github.com/ha0z1/idmp/tree/main/demo)

这样当模块 A 或者模块 B 的代码删除后,是不需要维护他们的缓存的。

Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"idmp": "1.14.4"
"idmp": "1.14.8"
},
"_dependencies": {
"idmp": "1.13.0-alpha.5"
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idmp",
"version": "1.14.6",
"version": "1.14.8",
"keywords": [
"deduplicate network requests",
"idempotent function",
Expand All @@ -16,7 +16,7 @@
"immutable data",
"auto retry"
],
"homepage": "https://idmp.vercel.app",
"homepage": "https://idmp-ha0z1.vercel.app",
"bugs": "https://github.com/ha0z1/idmp/issues",
"repository": {
"type": "git",
Expand All @@ -26,7 +26,8 @@
"type": "module",
"exports": {
".": "./dist/index.js",
"./node-fs": "./plugins/node-fs/dist/index.js"
"./node-fs": "./plugins/node-fs/dist/index.js",
"./browser-storage": "./plugins/browser-storage/dist/index.js"
},
"main": "./dist/index.node.cjs",
"module": "./dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions plugins/browser-storage/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# idmp/node-fs
# idmp/browser-storage

## Useage
## Usage

```typescript
import idmp from 'idmp'
Expand All @@ -27,3 +27,7 @@ getUserDataWithlocalStorageIdmp('123').then((data) => {

Cache data will be stored in `localStorage / sessionStorage` temporary directory and follow the same cache options as `idmp`.
If the data is in the memory, it is read from the memory first. If it is not in the memory, it is read from the `localStorage / sessionStorage`. If the cache validity period expires, it will be read from the remote end.

## Notice

Data persistence only supports string type `globalKey` and data structures that can be serialized by `JSON.stringify`
4 changes: 3 additions & 1 deletion plugins/browser-storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const storageIdmpWrap = (
const localData = storage.get(globalKey)
if (localData) {
if (process.env.NODE_ENV !== 'production') {
console.log(`[idmp-plugin browser-storage debug] ${globalKey} from ${storageType}["${getCacheKey(globalKey)}"]`)
console.log(
`[idmp-plugin browser-storage debug] ${globalKey} from ${storageType}["${getCacheKey(globalKey)}"]`,
)
}
return localData
}
Expand Down
6 changes: 5 additions & 1 deletion plugins/node-fs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# idmp/node-fs

## Useage
## Usage

```typescript
import idmp from 'idmp'
Expand All @@ -19,3 +19,7 @@ await fsIdmp(

Cache data will be stored in the `cacheDir` temporary directory and follow the same cache options as `idmp`.
If the data is in the memory, it is read from the memory first. If it is not in the memory, it is read from the file system. If the cache validity period expires, it will be read from the remote end.

## Notice

Data persistence only supports string type `globalKey` and data structures that can be serialized by `JSON.stringify`
10 changes: 2 additions & 8 deletions pnpm-lock.yaml

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

4 changes: 1 addition & 3 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"rewrites": [
{"source": "/(.*)", "destination": "/"}
]
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
}
2 changes: 1 addition & 1 deletion vite.demo.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default defineConfig({
define: {
// __DEV__: "process.env.NODE_ENV !== 'production'",
// 'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
})

0 comments on commit 1423072

Please sign in to comment.