short-uuid icon indicating copy to clipboard operation
short-uuid copied to clipboard

Add support for UUID v7

Open mfbx9da4 opened this issue 11 months ago • 1 comments

mfbx9da4 avatar Feb 28 '24 17:02 mfbx9da4

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);

oculus42 avatar Apr 29 '24 17:04 oculus42