import { __exports as pathType } from '../../../../../_virtual/index3.mjs';
import require$$0 from 'node:util';
import fs__default from 'node:fs';

const {
  promisify
} = require$$0;
const fs = fs__default;
async function isType(fsStatType, statsMethodName, filePath) {
  if (typeof filePath !== 'string') {
    throw new TypeError(`Expected a string, got ${typeof filePath}`);
  }
  try {
    const stats = await promisify(fs[fsStatType])(filePath);
    return stats[statsMethodName]();
  } catch (error) {
    if (error.code === 'ENOENT') {
      return false;
    }
    throw error;
  }
}
function isTypeSync(fsStatType, statsMethodName, filePath) {
  if (typeof filePath !== 'string') {
    throw new TypeError(`Expected a string, got ${typeof filePath}`);
  }
  try {
    return fs[fsStatType](filePath)[statsMethodName]();
  } catch (error) {
    if (error.code === 'ENOENT') {
      return false;
    }
    throw error;
  }
}
pathType.isFile = isType.bind(null, 'stat', 'isFile');
pathType.isDirectory = isType.bind(null, 'stat', 'isDirectory');
pathType.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
pathType.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
pathType.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
pathType.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');

export { pathType as default };
