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

proper-lockfile

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proper-lockfile

A inter-process and inter-machine lockfile utility that works on a local or network file system

  • 4.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is proper-lockfile?

The proper-lockfile npm package is used to create and manage file locks, ensuring that only one process can access a file at a time. This is particularly useful for preventing race conditions and ensuring data integrity in concurrent environments.

What are proper-lockfile's main functionalities?

Locking a file

This feature allows you to lock a file to prevent other processes from accessing it. The code sample demonstrates how to lock a file, perform some operations, and then release the lock.

const lockfile = require('proper-lockfile');

async function lockFile() {
  try {
    const release = await lockfile.lock('somefile');
    console.log('File is locked');
    // Do some work with the locked file
    await release();
    console.log('File is released');
  } catch (err) {
    console.error('Failed to lock file', err);
  }
}

lockFile();

Checking if a file is locked

This feature allows you to check if a file is currently locked. The code sample demonstrates how to check the lock status of a file.

const lockfile = require('proper-lockfile');

async function checkLock() {
  try {
    const isLocked = await lockfile.check('somefile');
    console.log(`File is ${isLocked ? 'locked' : 'not locked'}`);
  } catch (err) {
    console.error('Failed to check lock status', err);
  }
}

checkLock();

Unlocking a file

This feature allows you to manually unlock a file. The code sample demonstrates how to unlock a file that was previously locked.

const lockfile = require('proper-lockfile');

async function unlockFile() {
  try {
    await lockfile.unlock('somefile');
    console.log('File is unlocked');
  } catch (err) {
    console.error('Failed to unlock file', err);
  }
}

unlockFile();

Other packages similar to proper-lockfile

Keywords

FAQs

Package last updated on 25 Jan 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