# @aics/redux-utils 中文文档

规范地址：https://npmcn.com/package/%40aics/redux-utils/

版本：0\.6\.0
npm 元数据更新时间：2026-02-16T19:48:49.108Z
中文译文更新时间：2026-11-06T09:26:45.471Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aics/redux-utils
原文对照：https://npmcn.com/package/%40aics/redux-utils/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：48.7 kB，36 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：axios 0\.x，redux 4\.x，lodash 4\.x，redux-logic 3\.x
- 首次发布：2019-12-11T00:51:09.128Z
- 最新版本发布：2021-12-16T21:00:58.322Z
- 近 30 天下载量：3593（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：13（近 12 个月 0 个）

## 中文简介

与Redux合作的公用事业. 外面还有其他人 这是我们的.

## 安装

```sh
npm install @aics/redux-utils
```

也可以使用：`pnpm add @aics/redux-utils`、`yarn add @aics/redux-utils`、`bun add @aics/redux-utils`

## README

# @aics/ redux- utils

这个软件包抽取国家管理和测试公用事业 [饼干- 反应- 红色](https://aicsbitbucket.corp.alleninstitute.org/projects/COOK/repos/cookiecutter-react-redux/browse) 和别处.

所有函数,类和接口均从本软件包的顶层导出. 没有默认导出 。 例如:

```typescript
import { configureMockStore, ResponseStub, makeReducer } from "@aics/redux-utils";
```

* * *

## 实例:

1.  测试a `redux-logic` 逻辑响应一个动作,提出HTTP请求,并随HTTP请求的结果发出另一个动作. 为响应HTTP请求提供模拟值.

```typescript
import { configureMockStore } from "@aics/redux-utils";
import { expect } from "chai";

describe("configureMockStore", () => {
    interface State {
        foo: string;
        bar: number;
    }

    const initialState = {
        foo: "hello",
        bar: 123,
    };

    const simpleReducer: Reducer = (state = initialState, action) => {
        if (action.payload) {
            return {
                ...state,
                ...action.payload,
            };
        }

        return state;
    };

    const logic = createLogic({
        type: "TEST1",
        process: async (deps, dispatch, done) {
            const response = await deps.httpClient.get("/api/1.0/foo/bar");
            dispatch({ type: "TEST3", payload: response.data });
            done();
        },
    });

    const responseStub = {
        when: "/api/1.0/foo/bar",
        respondWith: { data: "Hello from the endpoint" },
    };

    // DON'T MISS THE ASYNC!
    it("creates a mock Redux store with some helpful defaults and utilies", async () => {
        const { store, actions, logicMiddleware } = configureMockStore<State>({
            state: initialState,
            reducer: simpleReducer,
            responseStubs: [responseStub]
            logics: [logic],
        });

        store.dispatch({ type: "TEST1" });

        // AFTER THIS POINT, ALL LOGICS HAVE FINISHED RUNNING
        await logicMiddleware.whenComplete();

        expect(actions.includes({ type: "TEST1" })).to.be.true;

        // dispatched by logic
        expect(actions.includes({ type: "TEST3", payload: "Hello from the endpoint" })).to.be.true;
    });
});
```

* * *

## 出口

#### 动作

-   函数 :
    
    -   \[批量动作\]\]
    -   \[可切入\]\]
-   接口 :
    
    -   \[批量行动\]\]

#### 动作跟踪器

-   类 :
    
    -   \[行动跟踪器\]\]
-   接口 :
    
    -   \[行动\]

#### 常数

-   函数 :
    -   \[\[恒 \]

#### 模拟- http客户端

-   职能
    
    -   \[\[创建MockHttclient\]\]
-   接口
    
    -   \[\[答复站

#### 模拟存储

-   职能
    
    -   \[\[构型MockStore\]\]\]
-   接口
    
    -   \[构图存储连接\]\]

#### 减少数

-   职能
    
    -   \[制作减
-   接口
    
    -   \[行动手 \]
    -   \[行动TypeThandlerMap\]\]

#### 状态

-   职能
    -   \[\[合并状态\]\]

#### 存储

-   职能
    
    -   \[构型站 \]
-   常数
    
    -   \[默认ReduxLogicDeps\]\]
-   接口 :
    
    -   \[构图堆肥\]\]
    -   \[ReduxLogic Dependencys\]\] (中文(简体) )

## 常见问题

### @aics/redux-utils 是什么？

与Redux合作的公用事业\. 外面还有其他人 这是我们的\.

### 如何安装 @aics/redux-utils？

在项目目录运行 npm install @aics/redux-utils，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：axios（0\.x）、redux（4\.x）、lodash（4\.x）、redux-logic（3\.x）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @aics/redux-utils 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @aics/redux-utils 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @aics/redux-utils 可以商用吗？

@aics/redux-utils 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @aics/redux-utils 的下载量有多少？

根据 npm 官方下载统计，@aics/redux-utils 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,593 次，日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @aics/redux-utils 还在维护吗？

最新版本 0\.6\.0 发布于 2021/12/17（4 年前）；至今共发布 13 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/12/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

