🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

redis-semaphore

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-semaphore - npm Package Compare versions

Comparing version

to
5.6.2

lib/tsconfig.build-commonjs.tsbuildinfo

1

lib/Lock.d.ts

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { AcquireOptions, LockLostCallback, LockOptions } from './types';

@@ -3,0 +2,0 @@ export declare abstract class Lock {

@@ -18,9 +18,19 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -43,2 +53,26 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

this._acquiredExternally = false;
this._processRefresh = async () => {
if (this._refreshing) {
debug(`already refreshing ${this._kind} (key: ${this._key}, identifier: ${this._identifier}) (skip)`);
return;
}
this._refreshing = true;
try {
debug(`refresh ${this._kind} (key: ${this._key}, identifier: ${this._identifier})`);
const refreshed = await this._refresh();
if (!refreshed) {
if (!this._acquired) {
debug(`refresh ${this._kind} (key: ${this._key}, identifier: ${this._identifier} failed, but lock was purposefully released`);
return;
}
this._acquired = false;
this.stopRefresh();
const lockLostError = new LostLockError_1.default(`Lost ${this._kind} for key ${this._key}`);
this._onLockLost(lockLostError);
}
}
finally {
this._refreshing = false;
}
};
if (identifier !== undefined &&

@@ -68,3 +102,2 @@ (!identifier || typeof identifier !== 'string')) {

this._refreshTimeInterval = refreshInterval;
this._processRefresh = this._processRefresh.bind(this);
this._onLockLost = onLockLost;

@@ -92,26 +125,2 @@ }

}
async _processRefresh() {
if (this._refreshing) {
debug(`already refreshing ${this._kind} (key: ${this._key}, identifier: ${this._identifier}) (skip)`);
return;
}
this._refreshing = true;
try {
debug(`refresh ${this._kind} (key: ${this._key}, identifier: ${this._identifier})`);
const refreshed = await this._refresh();
if (!refreshed) {
if (!this._acquired) {
debug(`refresh ${this._kind} (key: ${this._key}, identifier: ${this._identifier} failed, but lock was purposefully released`);
return;
}
this._acquired = false;
this.stopRefresh();
const lockLostError = new LostLockError_1.default(`Lost ${this._kind} for key ${this._key}`);
this._onLockLost(lockLostError);
}
}
finally {
this._refreshing = false;
}
}
async acquire() {

@@ -118,0 +127,0 @@ debug(`acquire ${this._kind} (key: ${this._key})`);

@@ -1,2 +0,2 @@

import LostLockError from '../src/errors/LostLockError';
import LostLockError from './errors/LostLockError';
export declare const defaultTimeoutOptions: {

@@ -8,2 +8,2 @@ lockTimeout: number;

};
export declare function defaultOnLockLost(err: LostLockError): void;
export declare function defaultOnLockLost(err: LostLockError): never;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultOnLockLost = exports.defaultTimeoutOptions = void 0;
exports.defaultTimeoutOptions = void 0;
exports.defaultOnLockLost = defaultOnLockLost;
exports.defaultTimeoutOptions = {

@@ -13,3 +14,2 @@ lockTimeout: 10000,

}
exports.defaultOnLockLost = defaultOnLockLost;
//# sourceMappingURL=misc.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireSemaphore = void 0;
exports.acquireSemaphore = acquireSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -39,3 +39,2 @@ const utils_1 = require("../../utils");

}
exports.acquireSemaphore = acquireSemaphore;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshSemaphore = void 0;
exports.refreshSemaphore = refreshSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -26,3 +26,2 @@ const lua_1 = require("./lua");

}
exports.refreshSemaphore = refreshSemaphore;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseSemaphore = void 0;
exports.releaseSemaphore = releaseSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -16,3 +16,2 @@ const lua_1 = require("./lua");

}
exports.releaseSemaphore = releaseSemaphore;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireMutex = void 0;
exports.acquireMutex = acquireMutex;
const debug_1 = __importDefault(require("debug"));

@@ -30,3 +30,2 @@ const utils_1 = require("../utils");

}
exports.acquireMutex = acquireMutex;
//# sourceMappingURL=acquire.js.map

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshMutex = exports.expireIfEqualLua = void 0;
exports.expireIfEqualLua = void 0;
exports.refreshMutex = refreshMutex;
const debug_1 = __importDefault(require("debug"));

@@ -32,3 +33,2 @@ const index_1 = require("../utils/index");

}
exports.refreshMutex = refreshMutex;
//# sourceMappingURL=refresh.js.map

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseMutex = exports.delIfEqualLua = void 0;
exports.delIfEqualLua = void 0;
exports.releaseMutex = releaseMutex;
const debug_1 = __importDefault(require("debug"));

@@ -26,3 +27,2 @@ const index_1 = require("../utils/index");

}
exports.releaseMutex = releaseMutex;
//# sourceMappingURL=release.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireRedlockMultiSemaphore = void 0;
exports.acquireRedlockMultiSemaphore = acquireRedlockMultiSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -38,3 +38,2 @@ const lua_1 = require("../multiSemaphore/acquire/lua");

}
exports.acquireRedlockMultiSemaphore = acquireRedlockMultiSemaphore;
//# sourceMappingURL=acquire.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshRedlockMultiSemaphore = void 0;
exports.refreshRedlockMultiSemaphore = refreshRedlockMultiSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -57,3 +57,2 @@ const lua_1 = require("../multiSemaphore/acquire/lua");

}
exports.refreshRedlockMultiSemaphore = refreshRedlockMultiSemaphore;
//# sourceMappingURL=refresh.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseRedlockMultiSemaphore = void 0;
exports.releaseRedlockMultiSemaphore = releaseRedlockMultiSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -17,3 +17,2 @@ const lua_1 = require("../multiSemaphore/release/lua");

}
exports.releaseRedlockMultiSemaphore = releaseRedlockMultiSemaphore;
//# sourceMappingURL=release.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireRedlockMutex = void 0;
exports.acquireRedlockMutex = acquireRedlockMutex;
const debug_1 = __importDefault(require("debug"));

@@ -38,3 +38,2 @@ const release_1 = require("../mutex/release");

}
exports.acquireRedlockMutex = acquireRedlockMutex;
//# sourceMappingURL=acquire.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshRedlockMutex = void 0;
exports.refreshRedlockMutex = refreshRedlockMutex;
const debug_1 = __importDefault(require("debug"));

@@ -48,3 +48,2 @@ const refresh_1 = require("../mutex/refresh");

}
exports.refreshRedlockMutex = refreshRedlockMutex;
//# sourceMappingURL=refresh.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseRedlockMutex = void 0;
exports.releaseRedlockMutex = releaseRedlockMutex;
const debug_1 = __importDefault(require("debug"));

@@ -17,3 +17,2 @@ const release_1 = require("../mutex/release");

}
exports.releaseRedlockMutex = releaseRedlockMutex;
//# sourceMappingURL=release.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireRedlockSemaphore = void 0;
exports.acquireRedlockSemaphore = acquireRedlockSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -38,3 +38,2 @@ const lua_1 = require("../semaphore/acquire/lua");

}
exports.acquireRedlockSemaphore = acquireRedlockSemaphore;
//# sourceMappingURL=acquire.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshRedlockSemaphore = void 0;
exports.refreshRedlockSemaphore = refreshRedlockSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -49,3 +49,2 @@ const lua_1 = require("../semaphore/acquire/lua");

}
exports.refreshRedlockSemaphore = refreshRedlockSemaphore;
//# sourceMappingURL=refresh.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseRedlockSemaphore = void 0;
exports.releaseRedlockSemaphore = releaseRedlockSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -16,3 +16,2 @@ const debug = (0, debug_1.default)('redis-semaphore:redlock-mutex:release');

}
exports.releaseRedlockSemaphore = releaseRedlockSemaphore;
//# sourceMappingURL=release.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireSemaphore = void 0;
exports.acquireSemaphore = acquireSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -39,3 +39,2 @@ const utils_1 = require("../../utils");

}
exports.acquireSemaphore = acquireSemaphore;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshSemaphore = void 0;
exports.refreshSemaphore = refreshSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -26,3 +26,2 @@ const lua_1 = require("./lua");

}
exports.refreshSemaphore = refreshSemaphore;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.releaseSemaphore = void 0;
exports.releaseSemaphore = releaseSemaphore;
const debug_1 = __importDefault(require("debug"));

@@ -15,3 +15,2 @@ const debug = (0, debug_1.default)('redis-semaphore:semaphore:release');

}
exports.releaseSemaphore = releaseSemaphore;
//# sourceMappingURL=release.js.map

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = createEval;
const crypto_1 = require("crypto");

@@ -28,3 +29,3 @@ const debug_1 = __importDefault(require("debug"));

catch (err) {
if (isNoScriptError(err)) {
if (err instanceof Error && isNoScriptError(err)) {
const evalArgs = [script, keysCount, ...args];

@@ -40,3 +41,2 @@ debug(connectionName, sha1, 'fallback to eval, args:', evalArgs);

}
exports.default = createEval;
//# sourceMappingURL=createEval.js.map
import { RedisClient } from '../types';
import createEval from './createEval';
export { createEval };
export declare function delay(ms: number): Promise<unknown>;
export declare function delay(ms: number): Promise<void>;
export declare function getConnectionName(client: RedisClient): string;

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getConnectionName = exports.delay = exports.createEval = void 0;
exports.createEval = void 0;
exports.delay = delay;
exports.getConnectionName = getConnectionName;
const createEval_1 = __importDefault(require("./createEval"));

@@ -13,3 +15,2 @@ exports.createEval = createEval_1.default;

}
exports.delay = delay;
function getConnectionName(client) {

@@ -19,3 +20,2 @@ const connectionName = client.options?.connectionName;

}
exports.getConnectionName = getConnectionName;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.smartSum = exports.getQuorum = void 0;
exports.getQuorum = getQuorum;
exports.smartSum = smartSum;
function getQuorum(clientCount) {
return Math.round((clientCount + 1) / 2);
}
exports.getQuorum = getQuorum;
function smartSum(count, zeroOrOne) {
return count + zeroOrOne;
}
exports.smartSum = smartSum;
//# sourceMappingURL=redlock.js.map
{
"name": "redis-semaphore",
"version": "5.6.1",
"version": "5.6.2",
"description": "Distributed mutex and semaphore based on Redis",

@@ -32,31 +32,30 @@ "main": "lib/index.js",

"@swarthy/wait-for": "^2.1.1",
"@swc-node/register": "1.9.1",
"@swc/core": "1.5.7",
"@types/chai": "^4.3.16",
"@swc-node/register": "1.10.10",
"@swc/core": "1.11.11",
"@types/chai": "^4.3.20",
"@types/chai-as-promised": "^7.1.8",
"@types/debug": "^4.1.12",
"@types/ioredis-mock": "^8",
"@types/mocha": "^10.0.6",
"@types/node": "20.12.12",
"@types/sinon": "^17.0.3",
"@types/ioredis-mock": "^8.2.5",
"@types/mocha": "^10.0.10",
"@types/node": "22.13.11",
"@types/sinon": "^17.0.4",
"@types/sinon-chai": "^3.2.12",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"@typescript-eslint/eslint-plugin": "8.27.0",
"@typescript-eslint/parser": "8.27.0",
"benchmark": "^2.1.4",
"chai": "4.4.1",
"chai": "4.5.0",
"chai-as-promised": "7.1.2",
"coveralls": "^3.1.1",
"eslint": "8.57.0",
"eslint-config-inclusive": "1.2.10",
"eslint": "9.23.0",
"eslint-plugin-node": "11.1.0",
"ioredis": "5.4.1",
"ioredis": "5.6.0",
"ioredis-mock": "8.9.0",
"mocha": "10.4.0",
"mocha": "11.1.0",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^15.1.0",
"sinon": "18.0.0",
"nyc": "^17.1.0",
"sinon": "19.0.4",
"sinon-chai": "3.7.0",
"snyk": "1.1291.0",
"snyk": "1.1296.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
"typescript": "^5.8.2"
},

@@ -75,5 +74,8 @@ "engines": {

"dependencies": {
"debug": "^4.3.4"
"debug": "^4.4.0"
},
"packageManager": "yarn@4.1.0+sha256.81a00df816059803e6b5148acf03ce313cad36b7f6e5af6efa040a15981a6ffb"
"packageManager": "yarn@4.1.0+sha256.81a00df816059803e6b5148acf03ce313cad36b7f6e5af6efa040a15981a6ffb",
"files": [
"lib/"
]
}

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

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

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

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

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

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