@dzeio/object-util

中文文档
1.9.3发布于 2026/09/25MITTypeScriptESM + CJS零依赖近 30 天下载 1.8万

操纵对象的工具功能

中文使用文档

对象 UTI

操纵对象的工具功能

使用量

  • 导入对象 UTI
import { objectMap, ... } from '@dzeio/object-util'
// or
const {objectMap, ...} = require('@dzeio/object-util')
  • 或从浏览器导入它
<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, ...}-->
  • 探险!

// 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 共发布 30 个版本,首次发布于 2020/09/11;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.9.3latest2026/09/251 个月前
1.9.22025/07/301.3 年前
1.9.12025/03/311.6 年前
1.9.02025/03/311.6 年前
1.8.32024/06/122 年前
1.8.22024/06/112 年前

关于 @dzeio/object-util 的常见问题

@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 和提交记录判断。