3.0.1 • Published 8 months ago

@lokalise/id-utils v3.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Id generation utils

This package adds common utils that provide IDs compatible with CockroachDB UUID type.

Usage

import { generateMonotonicUuid } from '@lokalise/id-utils'

const newId = generateMonotonicUuid()

Provided ID conforms with an abstract UUID representation (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) and is generated by ULID algorithm, which makes it lexicographically sortable. You can use basic language functions to sort by these ids:

import { generateMonotonicUuid } from '@lokalise/id-utils'

const ids = []

for (const i of Array(1000)) {
	ids.push(generateMonotonicUuid())
}

const sorted = ids.sort()

// sorted == ids

UUID7

This package also provides a function to generate a UUID7. It is a:

import { generateUuid7 } from '@lokalise/id-utils'

generateUuid7()
2.2.1

9 months ago

3.0.1

8 months ago

3.0.0

9 months ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

2 years ago

1.0.0

2 years ago