CodeQL library for JavaScript/TypeScript
codeql/javascript-all 0.8.15-dev (changelog, source)
Search

Member predicate API::Node::getForwardingFunction

Gets a node representing a function that is a wrapper around the function represented by this node.

Concretely, a function that forwards all its parameters to a call to f and returns the result of that call is considered a wrapper around f.

Examples:

function f(x) {
  return g(x); // f = g.getForwardingFunction()
}

function doExec(x) {
  console.log(x);
  return exec(x); // doExec = exec.getForwardingFunction()
}

function doEither(x, y) {
  if (x > y) {
    return foo(x, y); // doEither = foo.getForwardingFunction()
  } else {
    return bar(x, y); // doEither = bar.getForwardingFunction()
  }
}

function wrapWithLogging(f) {
  return (x) => {
    console.log(x);
    return f(x); // f.getForwardingFunction() = anonymous arrow function
  }
}
wrapWithLogging(g); // g.getForwardingFunction() = wrapWithLogging(g)
Node getForwardingFunction()