@upstash/lock
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -25,2 +25,6 @@ import { Redis } from '@upstash/redis'; | ||
retry?: RetryConfig; | ||
/** | ||
* The uuid to be used for the lock. | ||
*/ | ||
uuid?: string; | ||
}; | ||
@@ -27,0 +31,0 @@ type LockConfig = { |
@@ -48,3 +48,2 @@ "use strict"; | ||
// src/lock.ts | ||
var import_crypto = require("crypto"); | ||
var Lock = class { | ||
@@ -83,3 +82,12 @@ constructor(config) { | ||
let attempts = 0; | ||
const UUID = (0, import_crypto.randomUUID)(); | ||
let UUID; | ||
if (acquireConfig == null ? void 0 : acquireConfig.uuid) { | ||
UUID = acquireConfig.uuid; | ||
} else { | ||
try { | ||
UUID = crypto.randomUUID(); | ||
} catch (error) { | ||
throw new Error("No UUID provided and crypto module is not available in this environment."); | ||
} | ||
} | ||
while (attempts < retryAttempts) { | ||
@@ -86,0 +94,0 @@ const upstashResult = yield this.config.redis.set(this.config.id, UUID, { |
@@ -1,29 +0,1 @@ | ||
{ | ||
"name": "@upstash/lock", | ||
"description": "A distributed lock implementation using Upstash Redis", | ||
"module": "./dist/index.js", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"version": "0.2.0", | ||
"keywords": ["redis", "lock", "upstash", "redlock"], | ||
"author": "Meshan Khosla <meshan@upstash.com>", | ||
"license": "MIT", | ||
"files": ["dist"], | ||
"scripts": { | ||
"build": "tsup", | ||
"test": "bun test src --coverage", | ||
"fmt": "bunx @biomejs/biome check --apply ." | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.3.1", | ||
"@types/node": "^20.8.9", | ||
"@upstash/redis": "^1.24.1", | ||
"bun-types": "^1.0.7", | ||
"crypto": "^1.0.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} | ||
{ "name": "@upstash/lock", "description": "A distributed lock implementation using Upstash Redis", "module": "./dist/index.js", "main": "./dist/index.js", "types": "./dist/index.d.ts", "version": "v0.2.1", "keywords": [ "redis", "lock", "upstash", "redlock" ], "author": "Meshan Khosla <meshan@upstash.com>", "license": "MIT", "files": [ "dist" ], "scripts": { "build": "tsup", "test": "bun test src --coverage", "fmt": "bunx @biomejs/biome check --apply ." }, "devDependencies": { "@biomejs/biome": "1.3.1", "@types/node": "^20.8.9", "@upstash/redis": "^1.24.1", "bun-types": "^1.0.7", "tsup": "^7.2.0", "typescript": "^5.2.2" }, "peerDependencies": { "typescript": "^5.0.0" } } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39530
6
458
1