@exodus/basic-utils

中文文档
5.2.1发布于 2026/10/10MITTypeScriptES Module近 30 天下载 11.6万

Lightweight lodash-like utils.

原始使用文档
文档目录8 节
  1. Install
  2. Usage
  3. SynchronizedTime
  4. cleanInput
  5. flattenToPaths
  6. Lodash-like utility functions
  7. async helpers
  8. Prototype pollution safety

@exodus/basic-utils

npm

Lightweight lodash-like utils commonly used in Exodus projects.

Install

pnpm add @exodus/basic-utils

Usage

SynchronizedTime

import { SynchronizedTime } from '@exodus/basic-utils'

console.log(SynchronizedTime.now())

cleanInput

import { cleanInput } from '@exodus/basic-utils'

cleanInput('1.2abc@!#') // returns 1.2

flattenToPaths

Flatten an object to an array of [...path, leafValue] arrays.

import { flattenToPaths } from '@exodus/basic-utils'

flattenToPaths({
  harry: {
    wand: 'holly',
  },
  grindie: {
    wand: 'yew',
  },
  voldie: {
    wand: 'yew',
  },
})

// [
//   ['harry', 'wand', 'holly'],
//   ['grindie', 'wand', 'yew'],
//   ['voldie', 'wand', 'yew'],
// ]

Lodash-like utility functions

The following functions work like their lodash counterparts, with some caveats:

  • They're strict with respect to arguments, and don't support multiple options like arrays, strings, etc. For example, pick(users, ['name', 'age']) but NOT pick(users, 'name'). Please see the tests before you use them.
  • Functions that create objects return objects with a null prototype.

Before using a function, check its unit tests to make sure you're using the API correctly.

import {
  pick,
  pickBy,
  omit,
  mapKeys,
  mapValues,
  keyBy,
  orderBy,
  isNil,
  isObjectLike,
  isPlainObject,
  difference,
  intersection,
  partition,
  set,
} from '@exodus/basic-utils'

async helpers

See ./src/async.ts and ./src/p-debounce.ts for more details.

  • mapValuesAsync, filterAsync, partitionAsync are the async counterparts of mapValues, filter, partition respectively.
  • pDebounce: p-debounce, copied from the original temporarily to avoid having to ship this as ESM.

Prototype pollution safety

版本与发布记录

@exodus/basic-utils 共发布 53 个版本,首次发布于 2022/05/05;过去 12 个月发布了 9 个版本。

版本发布日期距今
5.2.1latest2026/10/101 个月前
5.2.02026/05/305 个月前
5.1.02026/05/225 个月前
5.0.12026/05/056 个月前
5.0.02026/04/097 个月前
3.7.62026/04/087 个月前

关于 @exodus/basic-utils 的常见问题

@exodus/basic-utils 是什么?

Lightweight lodash-like utils.

如何安装 @exodus/basic-utils?

在项目目录运行 npm install @exodus/basic-utils,或使用 pnpm add / yarn add / bun add。

@exodus/basic-utils 支持 TypeScript 吗?

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

@exodus/basic-utils 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/basic-utils 可以商用吗?

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

@exodus/basic-utils 的下载量有多少?

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

@exodus/basic-utils 还在维护吗?

最新版本 5.2.1 发布于 2026/10/10(1 个月前);至今共发布 53 个版本,其中过去 12 个月发布了 9 个;首次发布于 2022/05/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。