All files / engine/Source/Core wrapFunction.js

71.42% Statements 5/7
50% Branches 2/4
100% Functions 2/2
71.42% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                      13x       13x         13x 13x 13x        
import DeveloperError from "./DeveloperError.js";
 
/**
 * Wraps a function on the provided objects with another function called in the
 * object's context so that the new function is always called immediately
 * before the old one.
 *
 * @private
 */
function wrapFunction(obj, oldFunction, newFunction) {
  //>>includeStart('debug', pragmas.debug);
  Iif (typeof oldFunction !== "function") {
    throw new DeveloperError("oldFunction is required to be a function.");
  }
 
  Iif (typeof newFunction !== "function") {
    throw new DeveloperError("oldFunction is required to be a function.");
  }
  //>>includeEnd('debug');
 
  return function () {
    newFunction.apply(obj, arguments);
    oldFunction.apply(obj, arguments);
  };
}
export default wrapFunction;