UNPKG

@piyawasin/attempt

Version:

Inspired by Golang error handling, this package will help you code defensively by always handling the errors.

17 lines (16 loc) 393 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.attempt = void 0; function attempt(func) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } try { return [func.apply(void 0, args), null]; } catch (error) { return [null, error]; } } exports.attempt = attempt;