shorten-uuid
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

shorten-uuid

npm bundle size npm downloads license

github build coverage

Shorten UUID to a string of length 24.

The encoded character range is -0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.

The result is applicable to the URL and WeChat QR code.

Installation

NPM

npm install shorten-uuid
import shortenUuid from 'shorten-uuid';

Browser

Direct <script> include

<script src="https://cdn.jsdelivr.net/npm/shorten-uuid"></script>

Usage

const characters = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' // default value
const { encode, decode } = shortenUuid(characters);

const uuid = '2358e803-12d4-4741-8432-63e9137bd39b';
const encoded = encode(uuid); // -> 1CNDV20AJ3S07Fm5Ed0CvCDQ
decode(encoded); // -> 2358e803-12d4-4741-8432-63e9137bd39b

Package Sidebar

Install

npm i shorten-uuid

Weekly Downloads

14

Version

1.0.2

License

MIT

Unpacked Size

19.8 kB

Total Files

17

Last publish

Collaborators

  • cweili