File tree Expand file tree Collapse file tree 1 file changed +32
-2
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Original file line number Diff line number Diff 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 ( ) {
You can’t perform that action at this time.
0 commit comments