Skip to content

steve-232/generate-unique-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4dbde10 · Aug 7, 2023

History

60 Commits
Oct 29, 2020
Jul 31, 2023
Oct 16, 2020
Apr 30, 2018
Jul 31, 2023
Oct 29, 2020
Aug 7, 2023
Aug 7, 2023
Oct 16, 2020
Jul 31, 2023
Jul 31, 2023
Aug 7, 2023

Repository files navigation

Generate Unique ID

Generate a unique random ID string. GUI demo can be found here.

Installation

Using npm:

npm i generate-unique-id

Using yarn:

yarn add generate-unique-id

Using classic "src"

<script src="path/to/the/file/generateUniqueId.js"></script>

Usage

const generateUniqueId = require('generate-unique-id');

// example 1
const id1 = generateUniqueId();

// example 2
const id2 = generateUniqueId({
  length: 32,
  useLetters: false
});

// example 3
const id3 = generateUniqueId({
  includeSymbols: ['@','#','|'],
  excludeSymbols: ['0']
});

Options

Option Type Default Description
length number 20 Length of the generated ID.
useLetters boolean true Use letters (English alphabet) as part of the generated ID.
useNumbers boolean true Use numbers as part of the generated ID.
includeSymbols array [] Use additional letters as part of the generated ID.
excludeSymbols array [] Do not use these symbols as part of the generated ID.

License

MIT license