lodash-decorators
Version:
A collection of decorators using lodash at it's core.
26 lines (25 loc) • 658 B
TypeScript
import { BiTypedMethodDecorator } from './factory';
/**
* Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked.
* @param {...*} [args] The arguments to invoke func with.
* @example
*
* class MyClass {
* @Attempt()
* fn(value) {
* if (typeof value === 'number') {
* return value
* }
*
* throw new Error();
* }
* }
*
* const myClass = new MyClass();
*
* myClass.fn(10); // => 10;
* myClass.fn(null); // => Error
*/
export declare const Attempt: BiTypedMethodDecorator;
export { Attempt as attempt };
export default Attempt;