index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. const lockfile = require('./lib/lockfile');
  3. const { toPromise, toSync, toSyncOptions } = require('./lib/adapter');
  4. async function lock(file, options) {
  5. const release = await toPromise(lockfile.lock)(file, options);
  6. return toPromise(release);
  7. }
  8. function lockSync(file, options) {
  9. const release = toSync(lockfile.lock)(file, toSyncOptions(options));
  10. return toSync(release);
  11. }
  12. function unlock(file, options) {
  13. return toPromise(lockfile.unlock)(file, options);
  14. }
  15. function unlockSync(file, options) {
  16. return toSync(lockfile.unlock)(file, toSyncOptions(options));
  17. }
  18. function check(file, options) {
  19. return toPromise(lockfile.check)(file, options);
  20. }
  21. function checkSync(file, options) {
  22. return toSync(lockfile.check)(file, toSyncOptions(options));
  23. }
  24. module.exports = lock;
  25. module.exports.lock = lock;
  26. module.exports.unlock = unlock;
  27. module.exports.lockSync = lockSync;
  28. module.exports.unlockSync = unlockSync;
  29. module.exports.check = check;
  30. module.exports.checkSync = checkSync;