// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.import{ fromFileUrl }from"../path.ts"; typeExitsCallback=(exists:boolean)=>void; /** * TODO: Also accept 'path' parameter as a Node polyfill Buffer type once these * are implemented. See https://github.com/denoland/deno/issues/3403 * Deprecated in node api */exportfunctionexists(path:string|URL, callback:ExitsCallback):void{ path = path instanceofURL?fromFileUrl(path): path;Deno.lstat(path).then(()=>{callback(true);}).catch(()=>callback(false));} /** * TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these * are implemented. See https://github.com/denoland/deno/issues/3403 */exportfunctionexistsSync(path:string|URL):boolean{ path = path instanceofURL?fromFileUrl(path): path;try{Deno.lstatSync(path);returntrue;}catch(err){if(err instanceofDeno.errors.NotFound){returnfalse;}throw err;}}