1.0.2 • Published 7 months ago

@ethico/fakeuuid v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

FakeUUID

FakeUUID is a lightweight package for generating random UUIDs (Universal Unique Identifiers) with customizable options. Each time it creates totally unique id/ key.

Installation

To use FakeUUID, simply download the code from this repository and include it in your project. You can install the package using npm:

npm install @ethico/fakeuuid

Alternatively, you can download the FakeUUID.js file and include it in your project manually. or You can use the CDN for it

<script src="https://cdn.jsdelivr.net/gh/Shariar-Hasan/FakeUUID/src/FakeUUID.min.js"></script>

for importing :

import FakeUUID from "@ethico/fakeuuid";

Usage

const uuid = FakeUUID({
  startsWith: "user_",
  endsWith: "_id",
  length: 12,
  digit: true,
  lowerAlphabets: true,
  upperAlphabets: false,
  specialChars: "",
});
console.log(uuid); // Output: user_hivzjxod_id

Options

OptionDescriptionDefault valueRequired
startsWithA string with which the UUID should start.""optional
endsWithA string with which the UUID should end.""optional
lengthThe total length of the UUID.(excluding startsWith & endsWith)32optional
digitWhether to include digits in the UUID.trueoptional
lowerAlphabetsWhether to include lowercase letters in the UUID.trueoptional
upperAlphabetsWhether to include uppercase letters in the UUID.falseoptional
specialCharsA string containing special characters to be included in the UUID.""optional

You can use zero or more of the following options.

//          Example 
console.log(FakeUUID());
// ab3egdhs8f88safafssdjnbchfbdnsbb

console.log(FakeUUID({ length: 8, digit: true }));
// ab3e8f88

console.log(FakeUUID({ length: 8, upperAlphabets: true }));
// aB3e8F88

console.log(
  FakeUUID({ length: 8, upperAlphabets: true, lowerAlphabets: false })
);
// AB3E8F88

console.log(
  FakeUUID({
    startsWith: "$uid_",
    endsWith: "",
    length: 12,
    digit: true,
    lowerAlphabets: true,
    upperAlphabets: true,
    specialChars: "-",
  })
);
// $uid_dH3-Udh4

License

This project is licensed under the terms of the MIT license. See LICENSE file for details.

1.0.2

7 months ago

1.0.1

12 months ago

1.0.0

1 year ago