UNPKG

@qrvey/id-generator

Version:

![install size](https://packagephobia.com/badge?p=%40qrvey%2Fid-generator) ![coverage](https://img.shields.io/badge/unit_test_coverage-100%25-brightgreen)

50 lines (32 loc) 1.18 kB
# @qrvey/id-generator ![install size](https://packagephobia.com/badge?p=%40qrvey%2Fid-generator) ![coverage](https://img.shields.io/badge/unit_test_coverage-100%25-brightgreen) The `@qrvey/id-generator` package provides a simple utility function to generate unique IDs using the nanoid library, with customizable alphabet and length. ## Installation You can install the package using npm or yarn: ```bash npm install @qrvey/id-generator ``` Or with yarn: ```bash yarn add @qrvey/id-generator ``` ## Usage The getId function allows you to generate unique IDs with a customizable alphabet and length. ### Default Configuration - **`alphabet`**: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz - **`length`**: 21 ## Basic Example ```typescript import { getId } from '@qrvey/id-generator'; const id = getId(); console.log(id); // Example output: 'dZ3P1o2xY9B5RgTf8UAcW' ``` ## Custom Alphabet and Length ```typescript import { getId } from '@qrvey/id-generator'; const customAlphabet = '0123456789abcdef'; const customLength = 10; const customId = getId(customAlphabet, customLength); console.log(customId); // Example output: '4a8b7d3e1c' ```