From 281ddfcc06f293db266022b31b3d9cb9ea06f489 Mon Sep 17 00:00:00 2001 From: AVVS Date: Sat, 18 Jan 2025 21:48:43 -0800 Subject: [PATCH] fix: remove uuid dependency in favor of built-in crypto randomUUID --- package.json | 3 --- pnpm-lock.yaml | 12 ------------ src/lock.ts | 4 ++-- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index f9aab90..33e1373 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,6 @@ "type": "git", "url": "https://github.com/microfleet/ioredis-lock.git" }, - "dependencies": { - "uuid": "^11.0.5" - }, "peerDependencies": { "ioredis": "~4.x.x || ~5.x.x" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea90899..247f6da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,6 @@ settings: importers: .: - dependencies: - uuid: - specifier: ^11.0.5 - version: 11.0.5 devDependencies: '@makeomatic/deploy': specifier: ^13.1.0 @@ -325,7 +321,6 @@ packages: '@oxc-resolver/binding-linux-arm64-musl@3.0.3': resolution: {integrity: sha512-LdxbLv8qVkzro4/ZoP9MuytIL6NOVsbhoZ5Wl1KXOa/2DSxBiksrAPMSChCTyeLy6P3ebSHxQSb52ku18t1LBA==} - cpu: [arm64] os: [linux] '@oxc-resolver/binding-linux-x64-gnu@1.12.0': @@ -467,7 +462,6 @@ packages: '@swc/core-linux-arm64-musl@1.10.7': resolution: {integrity: sha512-gp5Un3EbeSThBIh6oac5ZArV/CsSmTKj5jNuuUAuEsML3VF9vqPO+25VuxCvsRf/z3py+xOWRaN2HY/rjMeZog==} engines: {node: '>=10'} - cpu: [arm64] os: [linux] '@swc/core-linux-x64-gnu@1.10.7': @@ -3035,10 +3029,6 @@ packages: uuid-parse@1.1.0: resolution: {integrity: sha512-OdmXxA8rDsQ7YpNVbKSJkNzTw2I+S5WsbMDnCtIWSQaosNAcWtFuI/YK1TjzUI6nbkgiqEyh8gWngfcv8Asd9A==} - uuid@11.0.5: - resolution: {integrity: sha512-508e6IcKLrhxKdBbcA2b4KQZlLVp2+J5UwQ6F7Drckkc5N9ZJwFa4TgWtsww9UG8fGHbm6gbV19TdM5pQ4GaIA==} - hasBin: true - uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -6583,8 +6573,6 @@ snapshots: uuid-parse@1.1.0: {} - uuid@11.0.5: {} - uuid@8.3.2: {} validate-npm-package-license@3.0.4: diff --git a/src/lock.ts b/src/lock.ts index 3357098..56a95e0 100644 --- a/src/lock.ts +++ b/src/lock.ts @@ -1,4 +1,4 @@ -import { v4 } from 'uuid' +import { randomUUID } from 'node:crypto' import { LockAcquisitionError, LockReleaseError, LockExtendError } from './errors.js' import { setTimeout as delay } from 'node:timers/promises' import * as scripts from './scripts.js' @@ -28,7 +28,7 @@ function getRandomArbitrary(min: number, max: number): number { export class Lock { static _acquiredLocks: Set = new Set() - private readonly _id: string = v4() + private readonly _id: string = randomUUID() private readonly _client: Redis | Cluster private _locked = false private _key: string | null = null