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

browser-tabs-lock

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-tabs-lock

provides locking mechanism to sync across browser tabs

  • 1.2.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
225K
decreased by-15.93%
Maintainers
3
Weekly downloads
 
Created

What is browser-tabs-lock?

The browser-tabs-lock npm package provides a mechanism to ensure that only one tab of a web application is active at a time. This is useful for preventing race conditions and ensuring data consistency when multiple tabs are open.

What are browser-tabs-lock's main functionalities?

Acquire a Lock

This feature allows you to acquire a lock with a specified key. If the lock is successfully acquired, you can perform operations that require the lock and then release it.

const { acquireLock } = require('browser-tabs-lock');

async function main() {
  const lock = await acquireLock('my-lock');
  if (lock) {
    console.log('Lock acquired');
    // Perform operations that require the lock
    lock.release();
  } else {
    console.log('Failed to acquire lock');
  }
}

main();

Release a Lock

This feature allows you to release a previously acquired lock. This is important to ensure that other tabs can acquire the lock when needed.

const { acquireLock } = require('browser-tabs-lock');

async function main() {
  const lock = await acquireLock('my-lock');
  if (lock) {
    console.log('Lock acquired');
    // Perform operations that require the lock
    lock.release();
    console.log('Lock released');
  } else {
    console.log('Failed to acquire lock');
  }
}

main();

Check Lock Status

This feature allows you to check if a lock with a specified key is currently acquired. This can be useful for debugging or for conditional logic based on lock status.

const { isLockAcquired } = require('browser-tabs-lock');

async function main() {
  const lockAcquired = await isLockAcquired('my-lock');
  if (lockAcquired) {
    console.log('Lock is currently acquired');
  } else {
    console.log('Lock is not acquired');
  }
}

main();

Other packages similar to browser-tabs-lock

Keywords

FAQs

Package last updated on 29 Apr 2021

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