UNPKG

vtils

Version:

一个面向业务的 JavaScript/TypeScript 实用程序库。

15 lines (14 loc) 361 B
import { init } from '@paralleldrive/cuid2'; import { memoize } from "../utils/index.js"; const createIdFactory = memoize(length => init({ length }), length => length); /** * 生成 Cuid2。 * * @param length 长度,默认: 24 * @see https://github.com/paralleldrive/cuid2 */ export function cuid2(length) { return createIdFactory(length || 24)(); }