Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vercel/uid-promise
Creates a cryptographically strong UID
https://github.com/vercel/uid-promise
guid uid uuid
Last synced: 27 days ago
JSON representation
Creates a cryptographically strong UID
- Host: GitHub
- URL: https://github.com/vercel/uid-promise
- Owner: vercel
- License: mit
- Created: 2016-03-07T22:45:16.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-05-18T01:59:43.000Z (over 1 year ago)
- Last Synced: 2024-05-12T02:33:13.928Z (6 months ago)
- Topics: guid, uid, uuid
- Language: TypeScript
- Homepage: https://npmjs.com/uid-promise
- Size: 38.1 KB
- Stars: 252
- Watchers: 7
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
- awesome-list - 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:
```js
npm i uid-promise
```Then import it:
```js
import { uid } = from 'uid-promise';
```Finally, call it:
```js
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
- Guillermo Rauch ([@rauchg](https://x.com/rauchg)) - [Vercel](https://vercel.com)
- Leo Lamprecht ([@notquiteleo](https://x.com/leo)) - [Vercel](https://vercel.com)