mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-28 14:54:38 +02:00
Fix:Include Watcher as lib with no dependencies and fix tiny-readdir bug #610
This commit is contained in:
parent
160dac109d
commit
ec6e70725c
34 changed files with 2187 additions and 281 deletions
25
server/libs/watcher/atomically/utils/attemptify.js
Normal file
25
server/libs/watcher/atomically/utils/attemptify.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
/* IMPORT */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.attemptifySync = exports.attemptifyAsync = void 0;
|
||||
const consts_1 = require("../consts");
|
||||
/* ATTEMPTIFY */
|
||||
//TODO: Maybe publish this as a standalone package
|
||||
//FIXME: The type castings here aren't exactly correct
|
||||
const attemptifyAsync = (fn, onError = consts_1.NOOP) => {
|
||||
return function () {
|
||||
return fn.apply(undefined, arguments).catch(onError);
|
||||
};
|
||||
};
|
||||
exports.attemptifyAsync = attemptifyAsync;
|
||||
const attemptifySync = (fn, onError = consts_1.NOOP) => {
|
||||
return function () {
|
||||
try {
|
||||
return fn.apply(undefined, arguments);
|
||||
}
|
||||
catch (error) {
|
||||
return onError(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
exports.attemptifySync = attemptifySync;
|
Loading…
Add table
Add a link
Reference in a new issue