@advanced-rest-client/uuid-generator

中文文档
3.1.2发布于 2021/03/03Apache-2.0ESM + CJS零依赖近 30 天下载 3350

An UUID generator as a web component

原始使用文档
文档目录9 节
  1. Usage
  2. Installation
  3. As a module
  4. In an html file (web component)
  5. In a LitElement
  6. Browser or a web worker
  7. Development
  8. Running the demo locally
  9. Running the tests

uuid-generator

An UUID v4 generator as a plain web component and an ES module. Made for a web browser.

Published on NPM

Build Status

Published on webcomponents.org

Usage

Installation

npm install --save @advanced-rest-client/uuid-generator

As a module

  import { v4 } from '@advanced-rest-client/uuid-generator';
  console.log(v4());

In an html file (web component)

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/uuid-generator';
    </script>
  </head>
  <body>
    <uuid-generator id="uuid"></uuid-generator>
    <script>
    console.log(uuid.generate());
    </script>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import { v4 } from '@advanced-rest-client/uuid-generator';

class SampleElement extends LitElement {
  render() {
    return html`my component`;
  }

  _someOperation() {
    const uuid = v4();
  }
}
customElements.define('sample-element', SampleElement);

Browser or a web worker

For historic reasons the index.js file contains an export for both the v4 function but also the web component. When using this module in a web worker or in Node this would cause an error. Instead import the module with the main.js file. For compatibility this file is not set as the module in the package.json file.

import { v4 } from '@advanced-rest-client/uuid-generator/main.js';

Development

git clone https://github.com/advanced-rest-client/uuid-generator
cd uuid-generator
npm install

Running the demo locally

npm start

Running the tests

npm test

版本与发布记录

@advanced-rest-client/uuid-generator 共发布 9 个版本,首次发布于 2019/02/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.2latest2021/03/035 年前
3.1.12020/10/226 年前
3.1.02020/05/206 年前
3.0.22019/09/127 年前
3.0.12019/06/067 年前
3.0.02019/06/027 年前

关于 @advanced-rest-client/uuid-generator 的常见问题

@advanced-rest-client/uuid-generator 是什么?

An UUID generator as a web component

如何安装 @advanced-rest-client/uuid-generator?

在项目目录运行 npm install @advanced-rest-client/uuid-generator,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/uuid-generator 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__uuid-generator 是否存在。

@advanced-rest-client/uuid-generator 支持 ESM 还是 CommonJS?

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

@advanced-rest-client/uuid-generator 可以商用吗?

@advanced-rest-client/uuid-generator 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@advanced-rest-client/uuid-generator 的下载量有多少?

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

@advanced-rest-client/uuid-generator 还在维护吗?

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