
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
In-memory two-phase locking for asynchronous JavaScript functions.
npm install 2pl
Multiple lock keys can be acquired during the lifetime of a lock instance, where release is done in one operation.
var lock = require('2pl')
var shared = {} // in-memory lock object shared across instances
var l = lock(shared, { ttl: 5000 }) // new instance, 5 seconds timeout
l.acquire('a', function (err) {
// a is locked
l.acquire('b', function (err) {
// b is locked
l.release(function (err) {
// a and b are released
})
})
})
Create a new instance with shared
object holding the in-memory locks.
Accepts following options:
ttl
: Time to live (milliseconds) of lock instance for liveness. Defaults to 20 seconds.Attempts to acquire a lock, given a string key
.
Accepts an optional callback function, invoked on success or error.
Attempts to extend ttl
of lock in milliseconds.
Accepts an optional callback function, invoked on success or error.
Attempts to release lock. Accepts an optional callback function, invoked on success or error.
Returns a factory function createLock([options])
that create instances under the same shared lock object.
var createLock = lock.creator({ ttl: 5000 })
var l1 = createLock() // ttl 5000
var l2 = createLock({ ttl: 500 }) // ttl 500
MIT
FAQs
Two-phase locking for asynchronous JavaScript executions.
The npm package 2pl receives a total of 13 weekly downloads. As such, 2pl popularity was classified as not popular.
We found that 2pl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.