Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redlock

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redlock - npm Package Compare versions

Comparing version 5.0.0-beta.1 to 5.0.0-beta2

7

CHANGELOG.md

@@ -33,1 +33,8 @@ ## v4.0.0

- **BREAKING** Change types for "using" helper (@ekosz via [#113](https://github.com/mike-marcacci/node-redlock/pull/114/)).
## v5.0.0-beta2
- Fix regression of retryCount: -1. (fixes #149)
- Export RedlockAbortSignal type. (fixes #138)
- Issue an improved error when passing non-integer durations. (fixes #120)
- Upgrade dependencies.

17

dist/cjs/index.js

@@ -207,2 +207,5 @@ "use strict";

var _a;
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const start = Date.now();

@@ -246,2 +249,5 @@ const value = this._random();

var _a;
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const start = Date.now();

@@ -273,3 +279,5 @@ // The lock has already expired.

: this.settings;
const maxAttempts = settings.retryCount + 1;
// For the purpose of easy config serialization, we treat a retryCount of
// -1 a equivalent to Infinity.
const maxAttempts = settings.retryCount === -1 ? Infinity : settings.retryCount + 1;
const attempts = [];

@@ -279,3 +287,3 @@ while (true) {

attempts.push(stats);
// The operation acheived a quorum in favor.
// The operation achieved a quorum in favor.
if (vote === "for") {

@@ -292,3 +300,3 @@ return { attempts };

else {
throw new ExecutionError("The operation was unable to acheive a quorum during its retry window.", attempts);
throw new ExecutionError("The operation was unable to achieve a quorum during its retry window.", attempts);
}

@@ -406,2 +414,5 @@ }

async using(resources, duration, settingsOrRoutine, optionalRoutine) {
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const settings = settingsOrRoutine && typeof settingsOrRoutine !== "function"

@@ -408,0 +419,0 @@ ? {

@@ -201,2 +201,5 @@ import { randomBytes, createHash } from "crypto";

var _a;
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const start = Date.now();

@@ -240,2 +243,5 @@ const value = this._random();

var _a;
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const start = Date.now();

@@ -267,3 +273,5 @@ // The lock has already expired.

: this.settings;
const maxAttempts = settings.retryCount + 1;
// For the purpose of easy config serialization, we treat a retryCount of
// -1 a equivalent to Infinity.
const maxAttempts = settings.retryCount === -1 ? Infinity : settings.retryCount + 1;
const attempts = [];

@@ -273,3 +281,3 @@ while (true) {

attempts.push(stats);
// The operation acheived a quorum in favor.
// The operation achieved a quorum in favor.
if (vote === "for") {

@@ -286,3 +294,3 @@ return { attempts };

else {
throw new ExecutionError("The operation was unable to acheive a quorum during its retry window.", attempts);
throw new ExecutionError("The operation was unable to achieve a quorum during its retry window.", attempts);
}

@@ -400,2 +408,5 @@ }

async using(resources, duration, settingsOrRoutine, optionalRoutine) {
if (Math.floor(duration) !== duration) {
throw new Error("Duration must be an integer value in milliseconds.");
}
const settings = settingsOrRoutine && typeof settingsOrRoutine !== "function"

@@ -402,0 +413,0 @@ ? {

4

dist/index.d.ts

@@ -52,3 +52,3 @@ /// <reference types="node" />

}
declare type RedlockAbortSignal = AbortSignal & {
export declare type RedlockAbortSignal = AbortSignal & {
error?: Error;

@@ -100,3 +100,3 @@ };

*/
acquire(resources: string[], duration: number, settings?: Settings): Promise<Lock>;
acquire(resources: string[], duration: number, settings?: Partial<Settings>): Promise<Lock>;
/**

@@ -103,0 +103,0 @@ * This method unlocks the provided lock from all servers still persisting it.

{
"name": "redlock",
"version": "5.0.0-beta.1",
"version": "v5.0.0-beta2",
"description": "A node.js redlock implementation for distributed redis locks",

@@ -48,14 +48,14 @@ "license": "MIT",

"devDependencies": {
"@types/ioredis": "^4.28.1",
"@types/node": "^16.11.10",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"ava": "^3.13.0",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"@types/ioredis": "^4.28.8",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"ava": "^4.1.0",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"ioredis": "^4.28.1",
"ioredis": "^4.28.5",
"nodemon": "^2.0.15",
"prettier": "^2.5.0",
"typescript": "~4.5.2"
"prettier": "^2.5.1",
"typescript": "~4.6.2"
},

@@ -62,0 +62,0 @@ "scripts": {

@@ -67,2 +67,4 @@ [![Continuous Integration](https://github.com/mike-marcacci/node-redlock/workflows/Continuous%20Integration/badge.svg)](https://github.com/mike-marcacci/node-redlock/actions/workflows/ci.yml?query=branch%3Amain++)

The first parameter is an array of resources to lock; the second is the requested lock duration in milliseconds, which MUST NOT contain values after the decimal.
```ts

@@ -103,2 +105,14 @@ await redlock.using([senderId, recipientId], 5000, async (signal) => {

### Use in CommonJS Projects
Beginning in version 5, this package is published primarily as an ECMAScript module. While this is universally accepted as the format of the future, there remain some interoperability quirks when used in CommonJS node applications. For major version 5, this package **also** distributes a copy transpiled to CommonJS. Please ensure that your project either uses either the ECMAScript or CommonJS version **but NOT both**.
The `Redlock` class is published as the "default" export, and can be imported with:
```ts
const { default: Redlock } = require("redlock");
```
In version 6, this package will stop distributing the CommonJS version.
## Error Handling

@@ -162,7 +176,1 @@

Note that with `retryCount=-1` there will be unlimited retries until the lock is aquired.
### Use in CommonJS projects
Beginning in version 5, this package is published as an ECMAScript module. While this is universally accepted as the format of the future, there remain some quirks when used in CommonJS node applications. To provide better erganomics for use in CommonJS projects, this package **also** distributes a CommonJS version. Please ensure that your project either uses the CommonJS or ECMAScript version **but NOT both**.
In version 6, this package will stop distributing a CommonJS version.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc