mainjs
Sets the unhandledRejection
to log to console.error
and provides a wrapper to emulate top-level await for scripts. main
will exit after the promise returned from f
resolves.
main(f:()=>Promise<any>):void
Runs f
and console.log
s "done" before exiting the process when the promise resolves.
If f
throws the exception is sent to console.error
.