npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

uuid-nanoid

v1.5.4

Published

A browser-friendly UUID and NanoID generator library with UMD packaging

Readme

UUID & NanoID UMD Library

一个用于浏览器环境的 UUID 和 NanoID 生成器库,提供 UMD 格式打包,开箱即用。 npm npm

特性

  • 🚀 多格式支持 - 提供 CommonJS、ES Module 和 UMD 三种打包格式
  • 🌐 浏览器优化 - 专为浏览器环境优化,无需构建工具即可使用
  • 🔒 Polyfill 支持 - 内置 crypto polyfill,确保在所有环境下正常工作
  • 📦 轻量级 - 多文件打包,按需使用
  • 完整 API - 支持 UUID v3/v4/v5 和 NanoID 所有功能
  • 📝 TypeScript 支持 - 提供类型声明文件

安装

npm 安装

npm install uuid-nanoid

yarn 安装

yarn add uuid-nanoid

直接使用

下载 dist/uuid-nanoid.umd.js 并在 HTML 中引入:

<script src="uuid-nanoid.umd.js"></script>

使用方法

在浏览器中直接使用

<!DOCTYPE html>
<html>
<head>
    <script src="dist/uuid-nanoid.umd.js"></script>
</head>
<body>
    <script>
        // 生成 NanoID
        const nanoId = UUIDNanoID.nanoid();
        
        // 生成 UUID v4
        const uuid = UUIDNanoID.uuidv4();
        
        // 使用模块
        const customNano = UUIDNanoID.NanoID.nanoid(10);
        const uuidV3 = UUIDNanoID.UUID.v3('test', UUIDNanoID.UUID.v3.DNS);
    </script>
</body>
</html>

在 Node.js/ESM 项目中使用

// ESM 导入
import UUIDNanoID from 'uuid-nanoid';

// CommonJS 导入
const UUIDNanoID = require('uuid-nanoid');

// 生成 NanoID
const nanoId = UUIDNanoID.nanoid();

// 生成 UUID v4
const uuid = UUIDNanoID.uuidv4();

// 使用模块
const customNano = UUIDNanoID.NanoID.nanoid(10);
const uuidV3 = UUIDNanoID.UUID.v3('test', UUIDNanoID.UUID.v3.DNS);

API 文档

NanoID

| 方法 | 说明 | 示例 | |------|------|------| | nanoid([size]) | 生成 NanoID | UUIDNanoID.nanoid() | | NanoID.nanoid([size]) | 同上 | UUIDNanoID.NanoID.nanoid(10) | | NanoID.customAlphabet(alphabet, [size]) | 自定义字符集 | UUIDNanoID.NanoID.customAlphabet('ABC', 8)() | | NanoID.customRandom(alphabet, size, random) | 自定义随机函数 | UUIDNanoID.NanoID.customRandom('ABC', 8, randomFn) | | NanoID.random(bytes) | 生成随机字节 | UUIDNanoID.NanoID.random(16) | | NanoID.urlAlphabet | URL 安全字母表 | UUIDNanoID.NanoID.urlAlphabet |

UUID

| 方法 | 说明 | 示例 | |------|------|------| | uuidv4() | 生成 UUID v4 | UUIDNanoID.uuidv4() | | UUID.v1([options]) | 生成 UUID v1 | UUIDNanoID.UUID.v1() | | UUID.v3(value, namespace) | 生成 UUID v3 | UUIDNanoID.UUID.v3('test', UUIDNanoID.UUID.v3.DNS) | | UUID.v4([options]) | 生成 UUID v4 | UUIDNanoID.UUID.v4() | | UUID.v5(value, namespace) | 生成 UUID v5 | UUIDNanoID.UUID.v5('test', UUIDNanoID.UUID.v5.DNS) | | UUID.v6([options]) | 生成 UUID v6 | UUIDNanoID.UUID.v6() | | UUID.v7([options]) | 生成 UUID v7 | UUIDNanoID.UUID.v7() | | UUID.NIL | 空 UUID | UUIDNanoID.UUID.NIL | | UUID.MAX | 最大 UUID | UUIDNanoID.UUID.MAX | | UUID.parse(uuid) | 解析 UUID | UUIDNanoID.UUID.parse(uuidStr) | | UUID.stringify(bytes) | 序列化 UUID | UUIDNanoID.UUID.stringify(bytes) | | UUID.validate(uuid) | 验证 UUID | UUIDNanoID.UUID.validate(uuidStr) | | UUID.version(uuid) | 获取 UUID 版本 | UUIDNanoID.UUID.version(uuidStr) | | UUID.v1ToV6(uuid) | 转换 v1 到 v6 | UUIDNanoID.UUID.v1ToV6(uuidStr) | | UUID.v6ToV1(uuid) | 转换 v6 到 v1 | UUIDNanoID.UUID.v6ToV1(uuidStr) |

浏览器兼容性

  • ✅ Chrome/Edge (最新版本)
  • ✅ Firefox (最新版本)
  • ✅ Safari (最新版本)
  • ✅ IE 11+ (需要 polyfill)

技术栈

  • uuid: ^14.0.0
  • nanoid: ^5.1.11
  • rollup: ^4.60.4

发布流程

一键发布

使用以下命令进行一键发布:

npm run release

发布脚本会自动:

  1. 检测未提交的更改并提示提交
  2. 询问版本升级类型(major/minor/patch/自定义)
  3. 自动更新版本号
  4. 生成/更新 CHANGELOG.md
  5. 创建 git tag
  6. 推送代码和 tag 到远程仓库

快速发布命令

# 大版本升级 (1.x.x -> 2.0.0)
npm run release:major

# 小版本升级 (1.0.x -> 1.1.0)
npm run release:minor

# 补丁升级 (1.0.0 -> 1.0.1)
npm run release:patch

提交信息规范

为了正确生成 changelog,请使用以下提交信息格式: | 类型 | 说明 | 示例 | |------|------|------| | feat | 新功能 | feat: 添加 UUID v6 支持 | | fix | 修复漏洞 | fix: 修复浏览器兼容性问题 | | docs | 文档更新 | docs: 更新 API 文档 | | chore | 构建/工具相关 | chore: 更新依赖 | | refactor | 代码重构 | refactor: 优化性能 | | test | 测试相关 | test: 添加单元测试 |

GitHub Actions

项目已配置 GitHub Actions,自动执行以下流程:

  • Push 到 main 分支: 自动构建验证
  • 创建 Release: 自动发布到 npm(需配置 NPM_TOKEN)

License

MIT