UNPKG

lux-framework

Version:

Build scalable, Node.js-powered REST APIs with almost no code.

27 lines (22 loc) 428 B
// @flow import { stat, readdir } from '../index'; /** * @private */ export default async function exists( path: string | RegExp, dir?: string ): Promise<boolean> { if (path instanceof RegExp) { const pattern = path; let files = []; if (dir) { files = await readdir(dir); } return files.some(file => pattern.test(file)); } return stat(path).then( () => true, () => false ); }