UNPKG

@eljs/utils

Version:
108 lines (106 loc) 2.82 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/file/is.ts var is_exports = {}; __export(is_exports, { isDirectory: () => isDirectory, isDirectorySync: () => isDirectorySync, isFile: () => isFile, isFileSync: () => isFileSync, isPathExists: () => isPathExists, isPathExistsSync: () => isPathExistsSync, isSymlink: () => isSymlink, isSymlinkSync: () => isSymlinkSync }); module.exports = __toCommonJS(is_exports); var import_meta = require("./meta"); async function isFile(file) { try { const stat = await (0, import_meta.fstat)(file); return stat ? stat.isFile() : false; } catch (_) { return false; } } function isFileSync(file) { try { const stat = (0, import_meta.fstatSync)(file); return stat ? stat.isFile() : false; } catch (_) { return false; } } async function isDirectory(path) { try { const stat = await (0, import_meta.fstat)(path); return stat ? stat.isDirectory() : false; } catch (_) { return false; } } function isDirectorySync(path) { try { const stat = (0, import_meta.fstatSync)(path); return stat ? stat.isDirectory() : false; } catch (_) { return false; } } async function isSymlink(link) { try { const stat = await (0, import_meta.fstat)(link, true); return stat ? stat.isSymbolicLink() : false; } catch (_) { return false; } } function isSymlinkSync(link) { try { const stat = (0, import_meta.fstatSync)(link, true); return stat ? stat.isSymbolicLink() : false; } catch (_) { return false; } } async function isPathExists(file) { try { const stat = await (0, import_meta.fstat)(file); return Boolean(stat); } catch (_) { return false; } } function isPathExistsSync(file) { try { const stat = (0, import_meta.fstatSync)(file); return Boolean(stat); } catch (_) { return false; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { isDirectory, isDirectorySync, isFile, isFileSync, isPathExists, isPathExistsSync, isSymlink, isSymlinkSync });