uid-promise

generates a cryptographically strong random uid

MIT 10 个版本
安装
npm install uid-promise
yarn add uid-promise
pnpm add uid-promise
bun add uid-promise
README

uid-promise

Creates a cryptographically secure UID with a 62 character range that can be safely used in URLs.

Usage

Install the package:

npm i uid-promise

Then import it:

import { uid } = from 'uid-promise';

Finally, call it:

await uid(20);

API

uid(Number len) => Promise

  • Return a Promise that resolves with a string of random characters of length len
  • len must always be provided, else the promise is rejected
  • Under the hood, crypto.randomBytes is used
  • Character set: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

Authors

版本列表
2.0.5 2023-05-18
2.0.4 2023-05-16
2.0.3 2023-05-16
2.0.2 2023-05-16
2.0.1 2023-05-15
2.0.0 2023-05-15
1.1.1 2021-08-17
1.1.0 2019-02-27
1.0.0 2017-06-16
0.1.0 2016-03-07