Skip to content

Commit

Permalink
Merge pull request #58 from oculus42/uuid/update-8.3.2
Browse files Browse the repository at this point in the history
4.2.0
  • Loading branch information
oculus42 authored May 13, 2021
2 parents b334e89 + 1306d77 commit 5a5227d
Show file tree
Hide file tree
Showing 5 changed files with 4,324 additions and 2,394 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.2.0] - 2021-05-13
### Added
- maxLength property to TypeScript definitions
- UUID types to TypeScript definitions

### Changed
- UUID version to 8.3.2
- Updated dev dependencies

## [4.1.0] - 2020-09-07
### Added
- maxLength property to translators
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@

Generate and translate standard UUIDs into shorter - or just *different* - formats and back.

## v4.1.0
## v4.2.0

### Major Changes in 4.0.0

- 🛑 short-uuid will now throw an error when provided an alphabet with duplicate characters. Duplicate characters will cause translation errors.
- ℹ️ 4.0.0 is written in modern ECMAScript. It uses features through ES9/ES2018.
- ℹ️ 4.x does not yet include the pre-built version for browsers. If needed, continue to use 3.1.1 in the meantime.
- ℹ️ By default, short-uuid will pad shortened IDs to a consistent length.
- Padding does not affect translation, and the values are compatible with previous releases.
- Padding can be disabled with the option `consistentLength: false` when instantiating a translator. This is consistent with previous versions.
- ℹ️ 4.x does not include a pre-built version for browsers. If needed, 3.1.1 is compatible, but does not pad to a consistent length.


### Quick Start

Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Simple wrapper functions to produce shorter UUIDs for cookies, maybe everything?
*/

const { v4: uuidv4 } = require('uuid');
const anyBase = require('any-base');
const uuidV4 = require('uuid').v4;

const flickrBase58 = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
const cookieBase90 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~";
Expand Down Expand Up @@ -89,12 +89,12 @@ module.exports = (() => {
// UUIDs are in hex, so we translate to and from.
const fromHex = anyBase(anyBase.HEX, useAlphabet);
const toHex = anyBase(useAlphabet, anyBase.HEX);
const generate = () => shortenUUID(uuidV4(), fromHex, paddingParams);
const generate = () => shortenUUID(uuidv4(), fromHex, paddingParams);

const translator = {
new: generate,
generate,
uuid: uuidV4,
uuid: uuidv4,
fromUUID: (uuid) => shortenUUID(uuid, fromHex, paddingParams),
toUUID: (shortUuid) => enlargeUUID(shortUuid, toHex),
alphabet: useAlphabet,
Expand All @@ -113,7 +113,7 @@ module.exports = (() => {
};

// Expose the generic v4 UUID generator for convenience
makeConvertor.uuid = uuidV4;
makeConvertor.uuid = uuidv4;

// Provide a generic generator
makeConvertor.generate = () => {
Expand Down
Loading

0 comments on commit 5a5227d

Please sign in to comment.