https://github.com/git-ced/uuid-base64-ts
Shorten UUID v4 to 22 characters with base64 encoding in Typescript
https://github.com/git-ced/uuid-base64-ts
base64 hacktoberfest uuid
Last synced: about 1 year ago
JSON representation
Shorten UUID v4 to 22 characters with base64 encoding in Typescript
- Host: GitHub
- URL: https://github.com/git-ced/uuid-base64-ts
- Owner: git-ced
- License: mit
- Created: 2021-04-29T02:56:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-30T15:41:46.000Z (over 4 years ago)
- Last Synced: 2024-05-30T16:37:08.141Z (about 2 years ago)
- Topics: base64, hacktoberfest, uuid
- Language: TypeScript
- Homepage:
- Size: 98.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uuid-base64-ts
> Shorten a UUID v4 to 22 characters with base64 encoding in Typescript
[](https://www.npmjs.com/package/uuid-base64-ts)




## Table of Contents
- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)
- [Authors](#authors)
- [Changelog](#changelog)
- [License](#license)
## Installation
This library is available through the [npm registry](https://www.npmjs.com/).
NPM
```bash
$ npm -i uuid-base64-ts
```
Yarn
```bash
$ yarn add uuid-base64-ts
```
## Setup
Start using it by importing the library first.
### CommonJS
```javascript
const base64 = require('uuid-base64-ts');
```
or
### ES6
```javascript
import { encode, decode } from 'uuid-base64-ts';
```
## Usage
**Shorten a UUID v4 to 22 characters with base64 encoding**
```javascript
import { encode } from 'uuid-base64-ts';
const uuidv4 = '85c39545-533c-4587-bb1d-bad766908b1b';
const shortId = encode(uuidv4);
console.log(shortId);
// => 'hcOVRVM8RYe7HbrXZpCLGw'
```
**Expand a base64 encoded character to UUID v4**
```javascript
import { decode } from 'uuid-base64-ts';
const shortId = 'hcOVRVM8RYe7HbrXZpCLGw';
const uuidv4 = decode(shortId);
console.log(uuidv4);
// => '85c39545-533c-4587-bb1d-bad766908b1b'
```
## Authors
- [Prince Neil Cedrick Castro](https://github.com/git-ced/) - Initial work
See also the list of [contributors](https://github.com/git-ced/uuid-base64-ts/contributors) who participated in this project.
## Changelog
[Changelog](https://github.com/git-ced/uuid-base64-ts/releases)
## License
[MIT](LICENSE)