Wraps two functions together into a new function that calls both. Both functions receive the same arguments, but the original function's output is always returned.
xtag.wrap(ORIGINAL, NEW)
xtag.wrap(ORIGINAL, NEW)
Arguments | Type | |
---|---|---|
ORIGINAL | Function | This function is called first within the wrapper function, and its output is always the returned value. |
NEW | Function | This function is the second one called within the wrapped function, it receives the same arguments as the original. |
var foo = function(){ alert(1); return 1 };
var bar = function(){ alert(2); return 2 };
var fooBar = xtag.wrap(foo, bar);
fooBar(); // alerts '1', then '2', returns the value 2