1.0.1 • Published 5 months ago

gen-unique-ids v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

gen-unique-ids

gen-unique-ids is a JavaScript utility for generating unique IDs with customizable options. It provides a simple way to create random IDs with varying lengths, including capital letters, small letters, numbers, and symbols.

Installation

import { genUniqueId } from "https://cdn.jsdelivr.net/gh/webdeveloper-sandeep/repository-version-control/gen-unique-ids/version@1.0.3.js";

!WARNING
Must include type="module" in script tag

<script src="script.js" type="module"></script>

2) You can install gen-unique-ids via npm:

install in terminal

npm i gen-unique-ids

use in file

const genUniqueId = require("gen-unique-ids");

how to use

  • if you just call the function

code

genUniqueId();

result

dTe2hJRBK2F1A8ampXJY; //A unique ID of length 20 every time
  • You can pass the length of the ID.

code

genUniqueId(12);
genUniqueId(5);

result

gGUdd272Oq3Y; //A unique ID of length 12 every time
mG3Fg; //A unique ID of length 5 every time
  • You can customize letter symbols and numbers in id by sending an object as an argument

code

const data = {
  length: 14, // Pass the length; by default, it is 20
  symbol: true, // Do you want to add symbols to the unique ID?
  lowercase: true, // Do you want to add lowercase letter to the unique ID?
  uppercase: true, // Do you want to add uppercase letter to the unique ID?
  number: true, // Do you want to add number to the unique ID?
};

genUniqueId(data);

result

2BOE@3fIfWp0u& // Generate a unique ID of length 14 each time, which includes lowercase letters, uppercase letters, numbers, and symbols
  • Create unique IDs like this: 0776UEeE-2442-8Y30-3585-GB4uo8nH

code

const data = {
  length: [8, 4, 4, 4, 8], // you can customise it
};

genUniqueId(data);

result

0776UEeE-2442-8Y30-3585-GB4uo8nH
  • Create unique IDs like this fh03j86h {customSeparator} PchR {customSeparator} TR6qgtkI using custom separator

code

const data = {
  length: [8, 4, 8],
  separate: "+", // By default, it is '-',
};

genUniqueId(data);

result

fh03j86h + PchR + TR6qgtkI;
  • Generate random ID with custom symbols

code

const data = {
  length: 13,
  symbol: "!@#", // If you set it to true by default, it becomes '!@#$%&'
};

genUniqueId(data);

result

u45D@T8N2#Ox4
  • Create unique IDs like this:
    24132-eizspf-7iA (num)-(lowercase)-(any)

code

const data = {
  length: [5, "number", 6, "lowercase", 3], // first 5 digits are only number next 6 digits are only lowercase and last 3 digits can be number , lowercase and uppercase
};

genUniqueId(data);

result

24132-eizspf-77A

!TIP "number" --- for Number "uppercase" --- for Uppercase letter "lowercase" --- for Lowercase letter "letter" --- for both uppercase and lowercase "symbol" --- for symbols

#creater

1.0.1

5 months ago

1.0.0

5 months ago