Socket
Socket
Sign inDemoInstall

async-lock

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-lock - npm Package Compare versions

Comparing version 1.2.8 to 1.3.0

4

History.md

@@ -0,1 +1,5 @@

1.3.0
==================
* Add maxOccupationTime option (Thank you @abozaralizadeh)
1.2.8

@@ -2,0 +6,0 @@ ==================

@@ -25,2 +25,3 @@ 'use strict';

this.timeout = opts.timeout || AsyncLock.DEFAULT_TIMEOUT;
this.maxOccupationTime = opts.maxOccupationTime || AsyncLock.DEFAULT_MAX_OCCUPATION_TIME;
if (opts.maxPending === Infinity || (Number.isInteger(opts.maxPending) && opts.maxPending >= 0)) {

@@ -34,2 +35,3 @@ this.maxPending = opts.maxPending;

AsyncLock.DEFAULT_TIMEOUT = 0; //Never
AsyncLock.DEFAULT_MAX_OCCUPATION_TIME = 0; //Never
AsyncLock.DEFAULT_MAX_PENDING = 1000;

@@ -74,7 +76,14 @@

var timer = null;
var occupationTimer = null;
var self = this;
var done = function (locked, err, ret) {
if (occupationTimer) {
clearTimeout(occupationTimer);
occupationTimer = null;
}
if (locked) {
if (self.queues[key].length === 0) {
if (!!self.queues[key] && self.queues[key].length === 0) {
delete self.queues[key];

@@ -149,2 +158,3 @@ }

};
if (self.domainReentrant && !!process.domain) {

@@ -185,2 +195,11 @@ exec = process.domain.bind(exec);

var maxOccupationTime = opts.maxOccupationTime || self.maxOccupationTime;
if (maxOccupationTime) {
occupationTimer = setTimeout(function () {
if (!!self.queues[key]) {
done(false, new Error('Maximum occupation time is exceeded'));
}
}, maxOccupationTime);
}
if (deferred) {

@@ -187,0 +206,0 @@ return deferred;

2

package.json
{
"name": "async-lock",
"description": "Lock on asynchronous code",
"version": "1.2.8",
"version": "1.3.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Rogier Schouten",

@@ -10,2 +10,3 @@ # async-lock

* Timeout supported
* Occupation time limit supported
* Pending task limit supported

@@ -135,2 +136,8 @@ * Domain reentrant supported

// Specify max occupation time
var lock = new AsyncLock({maxOccupationTime: 3000});
lock.acquire(key, fn, function(err, ret) {
// occupation time exceeded error will be returned here if job not completed in given time
});
// Set max pending tasks

@@ -137,0 +144,0 @@ var lock = new AsyncLock({maxPending: 1000});

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