Skip to content

Commit

Permalink
forgot about Node for a second
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispuska committed Jan 7, 2024
1 parent 3551649 commit 9a19d2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@heliosgraphics/utils",
"version": "5.1.0",
"version": "5.2.0",
"private": false,
"type": "module",
"author": "03b8 <[email protected]>",
"description": "Helios Utils",
"dependencies": {
"@heliosgraphics/library": "latest",
"xss": "^1.0.14"
"uuid": "latest",
"xss": "latest"
},
"engines": {
"npm": ">=10.2.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/uuid.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import crypto from "crypto"
import { v4 as uuidv4 } from "uuid"

const IS_TEST: boolean = process.env.NODE_ENV === "test"
export const TEST_UUID: string = "00000000-0000-0000-0000-000000000000" as const
export const TEST_UUID: string = "00000000-0000-0000-0000-000000000000"

export const getUUID = (id?: unknown): string | unknown => {
export const getUUID = (id?: unknown) => {
if (!!id) return id

// this is necessary for snapshot tests, but should be dynamic.
if (IS_TEST) return TEST_UUID

return crypto.randomUUID()
return uuidv4()
}

export const isUUID = (uuid?: unknown): boolean => {
Expand Down
10 changes: 9 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a19d2f

Please sign in to comment.