# uniquejs

> Generate unique and random strings, easily.

Latest version **1.2.0** (published 2021-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install uniquejs
pnpm add uniquejs
yarn add uniquejs
bun add uniquejs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-11-05 |
| First published | 2021-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Parik S. |
| Maintainers | parik36 |
| Keywords | uniquejs, unique, random, hex, uuid |

## Links

- npm: https://www.npmjs.com/package/uniquejs
- Repository: https://github.com/parik36/uniquejs
- Homepage: https://github.com/parik36/uniquejs#readme
- Issues: https://github.com/parik36/uniquejs/issues
- npm.io page: https://npm.io/package/uniquejs

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2021-11-05
- 1.0.0 — 2021-11-04

## README

# Unique.js

A JavaScript library to generate random strings based on a pattern/schema.

## Installation

Using npm:

```bash
npm install uniquejs
```

## Examples

```javascript
unique() // '08ycyk5878192wfm011lr7g6n1r40qtk'

unique(9) // '7q5o98g9g'

unique('aaa-nn-aaa_AA') // returns 'sor-50-kli_PT'

unique('anA') // returns 'p3S'

unique('A', 8) // 'MPGZACIY'
```

## Usage

```javascript
const unique = require('uniquejs');

unique() // '08ycyk5878192wfm011lr7g6n1r40qtk'
// returns a 32-character long alphanumberical string

unique(9) // '7q5o98g9g'
// returns an alphanumerical string of length of 9 characters

unique('n', 8) // '12934888'
unique('n') // '467463'
// returns a numerical string with length of 8 characters (defaults to 6 characters)

unique('a', 5) // 'gmlcv'
unique('a') // 'hgsdqz'
// returns a string of 5 lowercase characters (defaults to 6 characters)

unique('A', 8) // 'MPGZACIY'
unique('A') // 'UNIQUE'
// returns a  string of 8 uppercase characters (defaults to 6 characters)
````

Alternatively, you can use a custom schema/pattern to generate greatly customizable strings:

```javascript
const unique = require('uniquejs');

unique('aannAAnnaa') // returns 'bm07Q25ge'
unique('aaa-nn-aaa_AA') // returns 'sor-50-kli_PT'
unique('anA') // returns 'p3S'
```
where:

'n' represents a single-digit number (0-9)\
'a' represents a lowercase alphabet (a-z)\
'A' represents an uppercase alphabet (A-Z)

You can also add '-' and '_' to the schema to append the same at the specified index.

---
_Source: https://npm.io/package/uniquejs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
