UNPKG

functionalscript

Version:

FunctionalScript is a purely functional subset of JavaScript

17 lines (16 loc) 408 B
/** * Runs a function and exits the process with the returned code * Handles errors by exiting with code 1 */ export const run = (io) => { const code = ([x, b]) => { if (x === 'error') { io.console.error(b); return 1; } else { return b; } }; return async (f) => io.process.exit(code(await io.asyncTryCatch(() => f(io)))); };