# dyna-guid

> Javascript GUID generator

Latest version **2.2.1** (published 2024-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install dyna-guid
pnpm add dyna-guid
yarn add dyna-guid
bun add dyna-guid
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2024-06-16 |
| First published | 2017-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 90.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anel dev |
| Maintainers | dennisat |
| Keywords | guid |

## Links

- npm: https://www.npmjs.com/package/dyna-guid
- Repository: http://github.com/aneldev/dyna-guid
- npm.io page: https://npm.io/package/dyna-guid

## 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

- 2.2.1 (latest) — 2024-06-16
- 2.1.2 — 2022-01-24
- 2.1.1 — 2022-01-24
- 2.0.2 — 2022-01-23
- 2.0.1 — 2022-01-23
- 1.0.10 — 2018-11-10
- 1.0.9 — 2018-11-10
- 1.0.8 — 2018-03-01
- 1.0.7 — 2018-02-24
- 1.0.6 — 2018-02-24
- 1.0.5 — 2018-01-10
- 1.0.4 — 2017-10-20
- 1.0.3 — 2017-10-20
- 1.0.2 — 2017-08-05
- 1.0.1 — 2017-08-05

## README

# guid()

A simple guid generator based on timestamp!

**The chance to get the same guid is one in 18,446,744,073,709,600,000 on the same millisecond in the same timezone!**

## Samples

139aca66-2024bc60-2f847b9701be62a163 // Fixed length: 36

12f5ade5-54356610-2f847b9702f0b91635

216f48d8-233eb6b0-2f847b970379de20d6

## Comparison with others

```
dyna guid v2: 1e955ef4-47939014-2f847b9700c03a2a3b

dyna guid v1: 1g6263bg-1h2c3a89-18046497750547120

   .net guid: 30dd879c-ee2f-11db-8314-0800200c9a66
```

The difference is that dyna guid is 
- hard to generate the same on the same millisecond per timezone _and_
- impossible to generate the same on next millisecond!

## dyna guid syntax

```
<random block>-<random block>-<timestamp>
```

The default of the random blocks is 2, would be 1 or any other number.

## Usage

```
import {guid} from "dyna-guid";

console.log('guid', guid());
console.log('even stronger guid', guid(3));
  
```  

## Signature

`function guid(randomBlocks: number = 2): string`

Block is a set of 8 chars separated with dashes.

If you need even more complex guids (!why?) you can increase the number of blocks. Or for shorter set it to 1.

# Short GUID

Short GUID is a one block guid without hyphen. Useful for short unique ids, easy to copy-paste them.

## Samples

2024bc602f847b9701be62a163 // Fixed length: 26

543566102f847b9702f0b91635

233eb6b02f847b970379de20d6

## dyna guid syntax

```
<random block><timestamp>
```
## Usage

```
import {shortGuid} from "dyna-guid";

console.log('guid', shortGuid());
  
```  
## Signature

`function shortGuid(): string`

# Change log

## V1 05-Aug-2017

Sample: 1g6263bg-1h2c3a89-18046497750547120

## V2 20-Jan-2022

Sample: 18ee7d36-14d00ef3-2f847b9703c45725c7

- Fixed size, doesn't change cause current date
- Better random blocks

## V2 June-2024

- short guid

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