UNPKG

cross-process-lock

Version:

Cross-process file locking solution with lock-queue

24 lines 736 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withLock = withLock; const tslib_1 = require("tslib"); const lock_1 = require("./lock"); function withLock(file, options, callback) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (typeof options === "function") { callback = options; options = {}; } if (typeof callback !== "function") { throw new TypeError("Callback function must be set!"); } const unlock = yield (0, lock_1.lock)(file, options); try { return callback(); } finally { yield unlock(); } }); } //# sourceMappingURL=with.js.map