An open API service indexing awesome lists of open source software.

https://github.com/malted/unique

A Typescript UUID v4 implementation
https://github.com/malted/unique

uuid uuid-v4

Last synced: 4 months ago
JSON representation

A Typescript UUID v4 implementation

Awesome Lists containing this project

README

          

# unique

## A Typescript UUID v4 implementation

### Usage

#### Import the module

##### Deno
```js
import { uuid as uuidv4 } from "https://deno.land/x/unique/uuid.ts"
```

#### Generate a UUID

```js
const uuid: string = uuidv4();
console.log(uuid);
```

#### Validate the generated UUID

```js
import { v4 } from "https://deno.land/std@0.112.0/uuid/mod.ts";

const isValid: boolean = v4.validate(uuid);
console.log(isValid);
```

### Why

As per the MDN docs, `Crypto.randomUUID()` is _available only in secure contexts
(HTTPS), in some or all supporting browsers_.