UNPKG

@robotlegsjs/core

Version:

An architecture-based IoC framework for JavaScript/TypeScript

22 lines (21 loc) 810 B
/** * <p>Helper function to call any of the 3 forms of eventual callback: </p> * * <code>(), (error) and (error, message)</code> * * <p>NOTE: This helper will not handle null callbacks. You should check * if the callback is null from the calling location: </p> * * <code>callback &amp;&amp; safelyCallBack(callback, error, message);</code> * * <p>This prevents the overhead of calling safelyCallBack() * when there is no callback to call. Likewise it reduces the overhead * of a null check in safelyCallBack().</p> * * <p>QUESTION: Is this too harsh? Should we protect from null?</p> * * @param callback The actual callback * @param error An optional error * @param message An optional message */ export declare function safelyCallBack(callback: Function, error?: any, message?: any): void;