2023-10-03 11:14:36 +08:00
|
|
|
"use strict";
|
|
|
|
/* IMPORT */
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const fs = require("fs");
|
|
|
|
const util_1 = require("util");
|
|
|
|
const attemptify_1 = require("./attemptify");
|
|
|
|
const fs_handlers_1 = require("./fs_handlers");
|
|
|
|
const retryify_1 = require("./retryify");
|
|
|
|
/* FS */
|
|
|
|
const FS = {
|
|
|
|
chmodAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.chmod), fs_handlers_1.default.onChangeError),
|
|
|
|
chownAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.chown), fs_handlers_1.default.onChangeError),
|
|
|
|
closeAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.close)),
|
|
|
|
fsyncAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.fsync)),
|
|
|
|
mkdirAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.mkdir)),
|
|
|
|
realpathAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.realpath)),
|
|
|
|
statAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.stat)),
|
|
|
|
unlinkAttempt: attemptify_1.attemptifyAsync(util_1.promisify(fs.unlink)),
|
|
|
|
closeRetry: retryify_1.retryifyAsync(util_1.promisify(fs.close), fs_handlers_1.default.isRetriableError),
|
|
|
|
fsyncRetry: retryify_1.retryifyAsync(util_1.promisify(fs.fsync), fs_handlers_1.default.isRetriableError),
|
|
|
|
openRetry: retryify_1.retryifyAsync(util_1.promisify(fs.open), fs_handlers_1.default.isRetriableError),
|
|
|
|
readFileRetry: retryify_1.retryifyAsync(util_1.promisify(fs.readFile), fs_handlers_1.default.isRetriableError),
|
|
|
|
renameRetry: retryify_1.retryifyAsync(util_1.promisify(fs.rename), fs_handlers_1.default.isRetriableError),
|
|
|
|
statRetry: retryify_1.retryifyAsync(util_1.promisify(fs.stat), fs_handlers_1.default.isRetriableError),
|
|
|
|
writeRetry: retryify_1.retryifyAsync(util_1.promisify(fs.write), fs_handlers_1.default.isRetriableError),
|
|
|
|
chmodSyncAttempt: attemptify_1.attemptifySync(fs.chmodSync, fs_handlers_1.default.onChangeError),
|
|
|
|
chownSyncAttempt: attemptify_1.attemptifySync(fs.chownSync, fs_handlers_1.default.onChangeError),
|
|
|
|
closeSyncAttempt: attemptify_1.attemptifySync(fs.closeSync),
|
|
|
|
mkdirSyncAttempt: attemptify_1.attemptifySync(fs.mkdirSync),
|
|
|
|
realpathSyncAttempt: attemptify_1.attemptifySync(fs.realpathSync),
|
|
|
|
statSyncAttempt: attemptify_1.attemptifySync(fs.statSync),
|
|
|
|
unlinkSyncAttempt: attemptify_1.attemptifySync(fs.unlinkSync),
|
|
|
|
closeSyncRetry: retryify_1.retryifySync(fs.closeSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
fsyncSyncRetry: retryify_1.retryifySync(fs.fsyncSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
openSyncRetry: retryify_1.retryifySync(fs.openSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
readFileSyncRetry: retryify_1.retryifySync(fs.readFileSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
renameSyncRetry: retryify_1.retryifySync(fs.renameSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
statSyncRetry: retryify_1.retryifySync(fs.statSync, fs_handlers_1.default.isRetriableError),
|
|
|
|
writeSyncRetry: retryify_1.retryifySync(fs.writeSync, fs_handlers_1.default.isRetriableError)
|
|
|
|
};
|
|
|
|
/* EXPORT */
|
|
|
|
exports.default = FS;
|