cross-process-lock
Version:
Cross-process file locking solution with lock-queue
25 lines • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.withLock = void 0;
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();
}
});
}
exports.withLock = withLock;
//# sourceMappingURL=with.js.map