Skip to content

Commit aef0fa3

Browse files
committed
JS: Expand QLDoc
1 parent 2c65a49 commit aef0fa3

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,38 @@ module API {
348348
}
349349

350350
/**
351-
* Gets a node representing a function that wraps the current value, forwarding arguments and
352-
* return values.
351+
* Gets a node representing a function that is a wrapper around the function represented by this node.
352+
*
353+
* Concretely, a function that forwards all its parameters to a call to `f` and returns the result of that call
354+
* is considered a wrapper around `f`.
355+
*
356+
* Examples:
357+
* ```js
358+
* function f(x) {
359+
* return g(x); // f = g.getForwardingFunction()
360+
* }
361+
*
362+
* function doExec(x) {
363+
* console.log(x);
364+
* return exec(x); // doExec = exec.getForwardingFunction()
365+
* }
366+
*
367+
* function doEither(x, y) {
368+
* if (x > y) {
369+
* return foo(x, y); // doEither = foo.getForwardingFunction()
370+
* } else {
371+
* return bar(x, y); // doEither = bar.getForwardingFunction()
372+
* }
373+
* }
374+
*
375+
* function wrapWithLogging(f) {
376+
* return (x) => {
377+
* console.log(x);
378+
* return f(x); // f.getForwardingFunction() = anonymous arrow function
379+
* }
380+
* }
381+
* wrapWithLogging(g); // g.getForwardingFunction() = wrapWithLogging(g)
382+
* ```
353383
*/
354384
cached
355385
Node getForwardingFunction() {

0 commit comments

Comments
 (0)