# uneeqid

> Generate random strings of given length and type + check for unique

Latest version **1.0.10** (published 2018-06-09) · ISC license · 0 weekly downloads

## Install

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

## 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.0.10 |
| Published | 2018-06-09 |
| First published | 2018-04-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | chandru89new |
| Maintainers | chandru89new |
| Keywords | random, string, generator, id |

## Links

- npm: https://www.npmjs.com/package/uneeqid
- Repository: https://github.com/chandru89new/generateID
- Issues: https://github.com/chandru89new/generateID/issues
- npm.io page: https://npm.io/package/uneeqid

## 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.0.10 (latest) — 2018-06-09
- 1.0.9 — 2018-06-09
- 1.0.8 — 2018-04-27
- 1.0.7 — 2018-04-27
- 1.0.6 — 2018-04-27
- 1.0.5 — 2018-04-27
- 1.0.4 — 2018-04-27
- 1.0.3 — 2018-04-27
- 1.0.2 — 2018-04-25
- 1.0.1 — 2018-04-25
- 1.0.0 — 2018-04-25

## README

## What's this?

A random string generator. (Yes, there are lots of them, but this was built as a learning exercise).

## Demo

[Right here][0]

## How to use it?

Just like so:

```
var ID = require('uneeqid');
```

and then in your program:

```
ID.generate()
```

Works right out of the box. Without setting any options, you'll get a 64-character alphanumeric.

## Where can I use it?

Most likely when you want to create unique IDs for something like users, or links etc.

## How can I make sure the ID is unique?

So you can pass a list of IDs as an array to the library. Like so:

```
ID.list = ['...','...','...'];
ID.generate();
```

Or

```
var arr = [...]; // this is some array that you build. Like an array of all existing userIDs in your table
ID.list = arr;
ID.generate();
```

ID will automatically check if the generated ID is already in the list of IDs you fed into ID.list. If yes, it will re-generate another ID till it creates an ID that's unique.

## Options

When you use `ID.generate()` just like that, you get a 64-character long alphanumeric (with upper- and lower-case letters).

You can configure the length and the type of a string you want.

#### Type:

```
ID.type = 'loweralpha';
```

| Type | Explanation | Example (length = 16) |
| ---- | ----------- | --------------------- |
| alphanumeric | lower and upper case alphabets + numbers (0-9) | GejPA8BmYh55GuYU |
| loweralphanumeric | lowercase alphabets + numbers | djnzzm1eh7p1n82e |
| alpha | lower and upper case alphabets only | KmIQCOvZzLVHiIZw |
| numeric | numbers only | 8759684248582452 |
| loweralpha | lower case alphabets only | civjbazwxbwbaqgw |
| alphasymbol | alphabets and symbols | tlqQ_zXWa=l+ACFB |
| loweralphasymbol | lower case alphabets and symbols | @dw%uq$ms~i!$x)m |
| alphanumericsymbol | alphabets numbers and symbols | R^O=1Rz~A!qFB~58 |
| loweralphanumericsymbol | lower case alphabets, numbers and symbols | ?ucprlw)yut8$_wj |

#### Length:

Default is 64. You can give a number between 4 and 512 (both included). Anything off this will result in fallback to the default (64).

```
ID.length = 128;
```

## Mo' things to do with this:

```
ID.lastID
```
Gives you the last generated ID. Is changed whenever you use ID.generate();

```
ID.flush()
```
Flushes out `ID.list`

```
ID.reset()
```
Resets everything (type, length, list, lastID).

## Licence

No warranties whatsoever. Other than that, do whatever you want; no credits required.

[0]:http://druchan.com/gen_id

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