npm.io
3.0.0 • Published 6 months ago

file-exists-safe

Licence
MIT
Version
3.0.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0
Stars
2

file-exists-safe

npm typescript Coverage Status

Check if a file exists without try catch.

  • Returns true if the path exists and is a file.
  • Returns false if the path is not a file, or does not exist.
  • Returns undefined on other errors, such as permission denied, rather than throwing.

Installation

NPM
npm install file-exists-safe
Yarn
yarn add file-exists-safe
PNPM
pnpm add file-exists-safe
Bun
bun add file-exists-safe

Usage

import { fileExists, fileExistsSync, Options } from "file-exists-safe";

function fileExists(path: string, options?: Options): Promise<boolean | undefined>;

function fileExistsSync(path: string, options?: Options): boolean | undefined;

type Options = {
  /**
   * Return true if path is directory. Default: `false`
   */
  includeDirectories?: boolean;
};

License license

MIT - MIT License

  • fs-safe: A simple fs wrapper that doesn't throw
  • dir-exists-safe: Check if a directory exists without a try catch

Keywords