UNPKG

fs-extender

Version:
98 lines 3.2 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.areIdentical = exports.getCallback = exports.getSymlinkOptions = exports.getOptionsFile = exports.getOptionsDir = void 0; const utils_1 = require("@n3okill/utils"); const util = __importStar(require("../util")); /** @hidden */ function getOptionsDir(opt) { let mode; /* istanbul ignore next */ if (utils_1.Type.isNumeric(opt)) { mode = opt; } else if (opt && "mode" in opt) { mode = opt.mode; } else { mode = 0o777; } const options = {}; /* istanbul ignore next */ if (utils_1.Type.isNumeric(mode)) { if (utils_1.Type.isString(mode)) { options.mode = parseInt(mode, 8); } else { options.mode = mode; } } return options; } exports.getOptionsDir = getOptionsDir; /** @hidden */ function getOptionsFile(opt) { const options = getOptionsDir(opt); options.stream = util.getObjectOption(opt, "stream", false); options.flag = util.getObjectOption(opt, "flag", "wx"); const optAux = opt || {}; /* istanbul ignore next */ if ("dirMode" in optAux) { if (utils_1.Type.isNumeric(optAux.dirMode)) { if (utils_1.Type.isString(optAux.dirMode)) { options.dirMode = parseInt(optAux.dirMode, 8); } else { options.dirMode = optAux.dirMode; } } } if ("data" in optAux) { options.data = optAux.data; } /* istanbul ignore next */ if ("streamOptions" in optAux) { options.streamOptions = optAux.streamOptions; } if ("encoding" in optAux) { options.encoding = optAux.encoding; } return options; } exports.getOptionsFile = getOptionsFile; /* istanbul ignore next */ function getSymlinkOptions(opt = {}) { const options = {}; if ("type" in opt) { options.type = opt["type"]; } return options; } exports.getSymlinkOptions = getSymlinkOptions; exports.getCallback = util.getCallback; function areIdentical(srcStat, dstStat) { return (dstStat.ino !== undefined && dstStat.dev !== undefined && dstStat.ino === srcStat.ino && dstStat.dev === srcStat.dev); } exports.areIdentical = areIdentical; //# sourceMappingURL=util.js.map