05h

中文文档
1.0.0发布于 2026/09/11MITTypeScriptCommonJS零依赖

Stable 32-bit string hash (FNV-1a) with a bucketing helper. Zero dependencies.

原始使用文档
文档目录5 节
  1. API
  2. hash(value, modulo?)
  3. hash.bucket(value, buckets)
  4. Notes
  5. License

05h

Stable 32-bit string hash (FNV-1a) with a bucketing helper. Zero dependencies.

Same input always yields the same unsigned 32-bit integer on every platform and every Node version — suitable for stable sharding, cache keys and reproducible (seeded) ordering.

const hash = require('05h');

hash('hello');          // 1335831723
hash('hello');          // 1335831723   (always the same)
hash('hello', 100);     // 23           (in [0, 100))
hash.bucket('id', 8);   // 0..7         (shard index)

API

hash(value, modulo?)

ArgumentTypeDescription
valuestringInput. Non-strings are coerced with String().
modulonumber?When given, the result is reduced into [0, modulo). Invalid moduli are ignored.

Returns an unsigned 32-bit number.

hash.bucket(value, buckets)

Convenience wrapper returning a stable index in [0, buckets).

Notes

Not a cryptographic hash — do not use it for security purposes.

License

MIT

版本与发布记录

05h 共发布 1 个版本,首次发布于 2026/09/11;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0latest2026/09/111 个月前

关于 05h 的常见问题

05h 是什么?

稳定的32位字符串散列(FNV-1a)与bucket helper。零依赖关系。

如何安装 05h?

在项目目录运行 npm install 05h,或使用 pnpm add / yarn add / bun add。

05h 支持 TypeScript 吗?

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

05h 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

05h 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

05h 可以商用吗?

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

05h 还在维护吗?

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