@kilann/guid-generator
v1.3.4
Published
A utility to generate sortable and unique Comb GUIDs
Downloads
16
Maintainers
Readme
GUID_generator
A utility to generate Comb GUIDs
Installation
npm install @kilann/guid-generator
yarn add @kilann/guid-generator
pnpm add @kilann/guid-generatorWhy ?
This package is a simple utility to generate Comb GUIDs. A Comb GUID is a GUID that is generated from a timestamp and a UUID.
It make it sortable and unique.
You can pass in a prefix and/or suffix to the function, this will help you to identify the Comb GUID.
Fully without dependencies.
Usage
import { GUIDGenerator } from "@kilann/guid-generator";
const guid = GUIDGenerator();
console.log("guid:", guid);
// guid: 17e8e42f-02b9-4086-a4d8-30285f1819df
// you can also pass in a prefix and/or suffix
const pre_su_guid = GUIDGenerator("prefix", "suffix");
console.log("pre_su_guid:", pre_su_guid);
//pre_su_guid: prefix-17e8e42f-0354-48bb-a886-90c376d207bb-suffixOn the same way, you can create UUIDs
import { UUIDGenerator } from "@kilann/guid-generator";
const uuid = UUIDGenerator();
console.log("uuid:", uuid);
// uuid: 1e6129ba-2200-4fe8-9f77-1e862279d5b7
const pre_su_uuid = UUIDGenerator("prefix", "suffix");
console.log("pre_su_uuid:", pre_su_uuid);
// pre_su_uuid: prefix-fad2ece1-72f8-4ff2-89ec-efa344c3d9fc-suffixLicense
MIT
