Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function lock_and_read(name, cb) {
locker.readFile(name, {lock: true}, function(err, res) {
if (err) {
return cb(err);
}
return cb(null, res);
});
}
export function lockAndRead(name: string, cb: Callback): void {
locker.readFile(name, { lock: true }, (err, res) => {
if (err) {
return cb(err);
}
return cb(null, res);
});
}
const lock_and_read = function(name, cb) {
locker.readFile(name, {lock: true}, function(err, res) {
if (err) {
return cb(err);
}
return cb(null, res);
});
};
private _lockAndReadJSON(name: string, cb: Function) {
const fileName: string = this._getStorage(name);
readFile(
fileName,
{
lock: true,
parse: true
},
(err, res) => {
if (err) {
this.logger.trace({ name }, '[local-storage/_lockAndReadJSON] read new file: @{name} has failed');
return cb(err);
}
this.logger.trace({ name }, '[local-storage/_lockAndReadJSON] file: @{name} read');
return cb(null, res);
}
);
function unlock_file(name, cb) {
locker.unlockFile(name, cb);
}
export function unlockFile(name: string, cb: Callback): void {
locker.unlockFile(name, cb);
}
const unlock_file = function(name, cb) {
locker.unlockFile(name, cb);
};
private _unlockJSON(name: string, cb: Function) {
unlockFile(this._getStorage(name), cb);
}
}