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

@types/async-lock

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/async-lock

TypeScript definitions for async-lock

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
395K
decreased by-15.62%
Maintainers
1
Weekly downloads
 
Created

What is @types/async-lock?

@types/async-lock provides TypeScript type definitions for the async-lock library, which is used to manage asynchronous locks in JavaScript. This package helps ensure that your code is type-safe when using async-lock.

What are @types/async-lock's main functionalities?

Basic Locking

This feature allows you to create a lock on a specific key, ensuring that the critical section of code is executed exclusively.

const AsyncLock = require('async-lock');
const lock = new AsyncLock();

lock.acquire('key', function(done) {
    // Critical section
    console.log('Locked section');
    done();
}, function(err, ret) {
    // Lock released
    console.log('Lock released');
});

Timeouts

This feature allows you to set a timeout for the lock. If the lock is not acquired within the specified time, an error is returned.

const AsyncLock = require('async-lock');
const lock = new AsyncLock();

lock.acquire('key', function(done) {
    // Critical section
    setTimeout(() => {
        console.log('Locked section with timeout');
        done();
    }, 2000);
}, { timeout: 1000 }, function(err, ret) {
    if (err) {
        console.log('Lock timeout');
    } else {
        console.log('Lock released');
    }
});

Multiple Keys

This feature allows you to acquire locks on multiple keys simultaneously, ensuring that the critical section is executed only when all specified keys are locked.

const AsyncLock = require('async-lock');
const lock = new AsyncLock();

lock.acquire(['key1', 'key2'], function(done) {
    // Critical section
    console.log('Locked section with multiple keys');
    done();
}, function(err, ret) {
    // Lock released
    console.log('Lock released');
});

Other packages similar to @types/async-lock

FAQs

Package last updated on 26 Feb 2018

Did you know?

Socket

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.

Install

Related posts

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