@lokalise/id-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @lokalise/id-utils

Weekly Downloads

3,954

Version

2.0.0

License

none

Unpacked Size

5.05 kB

Total Files

8

Last publish

Collaborators

  • carlos_gamero
  • kibertoad
  • arthuracs
  • yury.kravtsov
  • filippos.mikropoulos
  • aplokalise
  • botlokalise
  • laurislokalise
  • marcocardosolok
  • bodrovis