oculus42 / short-uuid

Translate standard UUIDs into shorter formats and back.
MIT License
450 stars 13 forks source link

Add support for UUID v7 #71

Open mfbx9da4 opened 6 months ago

oculus42 commented 4 months ago

This is an interesting idea. I think with some minor rework short-uuid could accept any uuid generator as a source. This may be the target of the v6 release.

In the meantime, you can create a uuidv7 translator with just a few lines of code.

import short from 'short-uuid'
import { uuidv7 } from 'uuidv7';
const translator = short();

const v7Short = {
  ...translator,
  new: () => translator.fromUUID(uuidv7()),
  generate: () => translator.fromUUID(uuidv7()),
  uuid: uuidv7,
};

export default Object.freeze(v7Short);