Skip to content

Instantly share code, notes, and snippets.

@mikaelvesavuori
Created May 9, 2024 08:36
Show Gist options
  • Save mikaelvesavuori/a6ddc36def7680911dfadd8f0ce185b8 to your computer and use it in GitHub Desktop.
Save mikaelvesavuori/a6ddc36def7680911dfadd8f0ce185b8 to your computer and use it in GitHub Desktop.
Example of ULID to replace timestamps.
import { ulid, decodeTime } from 'ulidx';
const timestamp = () => parseInt(Date.now().toString());
const time = timestamp();
const ulidTime = ulid(time);
console.log('timestamp', time);
console.log('ulid', ulidTime);
console.log('ulid timestamp', decodeTime(ulidTime));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment