Skip to content
A bridge of flock(2) to Node.js
C++ JavaScript Shell CMake Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
script
test
.gitignore
.travis.yml
CMakeLists.txt
binding.gyp
common.h
flock.cc
index.js
package.json
readme.md

readme.md

node-flock

n-api enabled

A bridge of flock(2) to Node.js/ShadowNode in N-API.

API Reference

flock.lock(path, [options], callback)

Alias: flock.lockAsync(path, [options]) -> Promise<lock>

  • path: <string>
  • options.wait: <boolean> Default: false while lock is unavailable, if blocks current JavaScript execution context.
  • options.exclusive: <boolean> Default: false if acquires exclusive lock. Defaults to shared lock.
  • callback: <Function>
    • error: <Error>
    • lock: <integer> lock instance, currently it's a number.

Acquires the lock on the file.

flock.upgrade(lock, [options], callback)

Alias: flock.upgradeAsync(lock, [options]) -> Promise<lock>

  • lock: <integer>
  • options.wait: <boolean> Default: false while lock is unavailable, if blocks current JavaScript execution context.
  • options.exclusive: <boolean> Default: false if acquires exclusive lock. Defaults to shared lock.
  • callback: <Function>
    • error: <Error>
    • lock: <integer> lock instance, currently it's a number.

Upgrades the lock previously acquired.

flock.unlock(lock, callback)

Alias: flock.unlockAsync(lock) -> Promise<void>

  • lock: <integer>
  • callback: <Function>
    • error: <Error>

Unlocks previously acquired lock.

You can’t perform that action at this time.