import { stat , Stats } from "fs" ; import { blank } from "./String" ; export async function isFileEmpty ( path ) { if ( blank ( path ) ) { throw new Error ( "isFileEmpty(): blank path" ) ; } try { const s = await new Promise < Stats > ( ( res , rej ) => { try { stat ( path , ( err , val ) => ( err == null ? res ( val ) : rej ( err ) ) ) ; } catch ( err ) { rej ( err ) ; } } ) ; return s == null || s . size === 0 ; } catch ( err ) { if ( err . code === "ENOENT" ) return true ; else throw err ; } }