npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fcf-framework-lock

v1.0.12

Published

Provides file locking and named mutex functionality

Downloads

38

Readme

fcf-framework-lock

Packet provides functions for locking on a file and named mutexes. The package is compatible with UNIX systems and Windows.

Supported OS: UNIX & Windows

The package supports NODEJS version 6 and all following.

Package description page: https://fcf-framework.tech/packages/fcf-framework-lock

lockFile(string a_filePath, function a_cb)

lockFile(number a_fileHandle, function a_cb)

Performs a file lock

  • string a_filePath - The path to the file.
  • number a_fileHandle - The open file handle returned by the FS.open() functions.
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, number a_lock)
      • Error|undefined a_error - If the function executed with an error, then the argument contains an error object
      • number a_lock - Contains a lock handle to be passed to the unlockFile function to unlock the file.

tryLockFile(string a_filePath, function a_cb)

tryLockFile(number a_fileHandle, function a_cb)

tryLockFile(string a_filePath, boolean a_quiet, function a_cb)

tryLockFile(number a_fileHandle, boolean a_quiet, function a_cb)

Performs a lock on the file, if the file already has a lock, the function fails (the "unavailable" property of the error object is set to true)

  • string a_filePath - The path to the file.
  • number a_fileHandle - The open file handle returned by the FS.open() functions.
  • boolean a_quiet = false - If true, then if a lock is held on a file that is already locked, the function exits without error, and the value of the a_lock argument in the callback function is undefined. If the value is not set or is false, then if the file is already locked, the function will fail with an error object containing an "unavailable" field equal to true.
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, number a_lock)
      • Error|undefined a_error - Error object. If the function was locking on an already locked file, then the error object will contain the "unavailable" property set to true.
      • number a_lock - If successful, contains a lock handle that must be passed to the unlockFile function to unlock the file.

unlockFile(number a_lock, function a_cb)

Performs file unlocking

  • number a_lock - The lock handle.
  • function a_cb - The function of processing the result of the function execution.
    • Function signature a_cb: a_cb(Error|undefined a_error)
      • Error|undefined a_error - Error object.

isLockFile(string a_filePath, function a_cb)

isLockFile(number a_fileHandle, function a_cb)

Checks if the file is locked.

  • string a_filePath - The path to the file.
  • number a_fileHandle - The open file handle returned by the FS.open() functions.
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, boolean a_isLocked)
      • Error|undefined a_error - Error object.
      • boolean a_isLocked - True if the file has a lock.

lockNamedMutex(string a_name, function a_cb)

Locks a named mutex

  • string a_name - The mutex name
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, number a_lock)
      • Error|undefined a_error - If the function executed with an error, then the argument contains an error object
      • number a_lock - Contains a lock handle to be passed to the unlockNamedMutex function to unlock the mutex.

tryLockNamedMutex(string a_name, function a_cb)

tryLockNamedMutex(string a_name, boolean a_quiet, function a_cb)

Tries to lock a named mutex without waiting. If the mutex already has a lock, the function fails (the "unavailable" property of the error object is set to true)

  • string a_name - The mutex name
  • boolean a_quiet = false - If true, then if a lock is held that is already locked, the function exits without error, and the value of the a_lock argument in the callback function is undefined. If the value is not set or is false, then if the mutex is already locked, the function will fail with an error object containing an "unavailable" field equal to true.
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, number a_lock)
      • Error|undefined a_error - Error object. If the function was locking on an already locked mutex, then the error object will contain the "unavailable" property set to true.
      • number a_lock - If successful, contains a lock handle that must be passed to the unlockNamedMutex function to unlock the mutex.

unlockNamedMutex(number a_lock, function a_cb)

Performs a mutex unlock

  • number a_lock - The lock ID obtained by the lockNamedMutex tryLockNamedMutex functions
  • function a_cb - The function of processing the result of the function execution.
    • Function signature a_cb: a_cb(Error|undefined a_error)
      • Error|undefined a_error - Error object.

isLockNamedMutex(string a_name, function a_cb)

Checks whether the named mutex is locked

  • string a_name - The mutex name
  • function a_cb - The function of processing the result of the function execution.
    • Function signature: a_cb(Error|undefined a_error, boolean a_isLocked)
      • Error|undefined a_error - Error object.
      • boolean a_isLocked - True if the mutex has a lock.