# als-uid

> A utility to generate unique identifiers with cryptographic randomness and time-based elements.

Latest version **1.2.1** (published 2025-05-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install als-uid
pnpm add als-uid
yarn add als-uid
bun add als-uid
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2025-05-13 |
| First published | 2023-11-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex Sorkin |
| Maintainers | alexsorkin |
| Keywords | uid, unique identifier, crypto, random, utility |

## Links

- npm: https://www.npmjs.com/package/als-uid
- npm.io page: https://npm.io/package/als-uid

## 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.1 (latest) — 2025-05-13
- 1.2.0 — 2025-05-13
- 1.1.0 — 2023-11-29
- 1.0.1 — 2023-11-12
- 1.0.0 — 2023-11-12

## README

# Als-uid

ALS-UID is a JavaScript utility for generating unique identifiers (UIDs). It combines cryptographic randomness with time-based elements to ensure a high degree of uniqueness and reduce the likelihood of collisions.

## import

In Node.js
```js
const GenerateUid = require('als-uid')
```

In browser:
```html
<script src="node_modules/als-uid/index.js"></script>
```

## Usage

```javascript
// Generate a UID
const uid = GenerateUid.uid();
console.log(uid); // Outputs a unique identifier 14 symbols

// Change how often the prefix is updated
GenerateUid.changePrefixEvery = 200; // 100 by default
GenerateUid.prefix // curent generated prefix
```

## Performace
Tests showed that prefix generation (on start and every 100 generations by default) takes about 1ms.
Every generation without prefix (each of 99 generations by default), takes about 0.1ms - 0.2ms.

## Generation method
als-uid using unique method for uid generation.
Each uid has 3 parts:
1. **prefix** - secure cryptographic random string from 2 bytes
   1. changing on start or every 100 times by default
2. **Random string** - random 3 length string (generated with Math.random)
3. **modified date digits** - last 7 digits from Date.now() - random numbers from performance.now()

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