inject_code: Injects code into an existing function.

Description Usage Arguments Details Value

View source: R/inject-code.R

Description

The code argument is recorded without evaluation and it will be inserted at the beginning of the fun. If it is a symbol, its value will be looked starting in the callee frame. If where is not onentry it will be wrapped in on.exit call. If where is onerror, the wrapped code will further make the code to run only in the case the function failed with an error condition.

Usage

1
inject_code(code, fun, where = "onentry", wrap = FALSE)

Arguments

code

the code that should be inserted.

fun

the function into which the code should be inserted.

where

indicates at which point of the fun invocation the given code shall run. It can be one of the following: onentry, onexit, onsuccess, onerror.

wrap

indicates if it the given code should be wrapped in an anonymous function (TRUE) or inserted as is (FALSE).

Details

This function modifies the original function.

Value

NULL invisibly


PRL-PRG/injectr documentation built on July 7, 2020, 6:44 p.m.