# @dzeio/object-util 中文文档

规范地址：https://npmcn.com/package/%40dzeio/object-util/

版本：1\.9\.3
npm 元数据更新时间：2026-09-25T14:38:35.214Z
中文译文更新时间：2026-11-13T02:48:53.993Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40dzeio/object-util
原文对照：https://npmcn.com/package/%40dzeio/object-util/?lang=original
项目主页：https://github.com/dzeiocom/libs/tree/master/packages/object-util
源码仓库：https://github.com/dzeiocom/libs

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

- 包体积（解压后）：67.7 kB，9 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2020-09-11T08:42:48.750Z
- 最新版本发布：2026-09-25T14:38:35.030Z
- 近 30 天下载量：18212（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 1 个）

## 中文简介

操纵对象的工具功能

## 安装

```sh
npm install @dzeio/object-util
```

也可以使用：`pnpm add @dzeio/object-util`、`yarn add @dzeio/object-util`、`bun add @dzeio/object-util`

## README

# 对象 UTI

操纵对象的工具功能

## 使用量

-   导入对象 UTI

```typescript
import { objectMap, ... } from '@dzeio/object-util'
// or
const {objectMap, ...} = require('@dzeio/object-util')
```

-   或从浏览器导入它

```html
<script src="https://cdn.jsdelivr.net/npm/@dzeio/object-util@1/dist/browser.js"></script>
<!-- each functions will be available as window.{objectMap, ...} or {objectMap, ...}-->
```

-   探险!

```typescript

// Does the same as Array.map
objectMap(object, (value, key) => value + "pouet")

// does the same as Array.forEach with the addition of stopping if false is returned (like break)
// and return if loop was stopped or not
objectLoop(object, (value, key) => {})

// return the values of an object as an array
objectValues(object)

// return the keys of an object as an array
ObjectKeys(object)

// return the count of an object keys
objectSize(object)

// like Array.sort it sort and return an ordered object
objectSort(object, /*optionnal*/ (key1, key2) => key1 - key2)

// You can also sort by keys
// items not set in the array won't have their order changed and will be after the sorted ones
objectSort(object, ['key2', 'key1']) // => {key2: value, key1: value, key3: value}

// deeply clone an object
cloneObject(object)

// deeply set an object value while creating empty childs if necessary
//ex: this will set {path1, [{path3: 'value'}]} if object is an empty object
objectSet(object, ['path1', 0, 'path3'], 'value')

// deeply compare two objects
objectEqual(object, object2)

// deeply clean an object from undefined, null variables
objectClean(object, /* optionnal, defaults */{cleanUndefined: true, cleanNull: false, deep: true})

// clone (not deeply) an object and remove the keys from the object, 'a' and 'b' for this one
objectOmit(object, 'a', 'b')

// check if a variable is an object
isObject(object)
```

_备注:除是对象外,如果对象不是对象,每个函数都会出错_

## 常见问题

### @dzeio/object-util 是什么？

操纵对象的工具功能

### 如何安装 @dzeio/object-util？

在项目目录运行 npm install @dzeio/object-util，或使用 pnpm add / yarn add / bun add。

### @dzeio/object-util 支持 TypeScript 吗？

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

### @dzeio/object-util 支持 ESM 还是 CommonJS？

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

### @dzeio/object-util 可以商用吗？

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

### @dzeio/object-util 的下载量有多少？

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

### @dzeio/object-util 还在维护吗？

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

